예제 #1
0
static int hwc_hdmi_switch(void)
{
    SUNXI_hwcdev_context_t *ctx = &gSunxiHwcDevice;
    
    if(ctx->psHwcProcs && ctx->psHwcProcs->hotplug)
    {
        unsigned long arg[4]={0};

        if(ctx->hdmi_hpd)
        {
            __disp_tv_mode_t hdmi_mode;
            if(ctx->cur_3d_mode[1] == DISPLAY_3D_LEFT_RIGHT_HDMI || ctx->cur_3d_mode[1] == DISPLAY_3D_TOP_BOTTOM_HDMI)
                hdmi_mode = DISP_TV_MOD_1080P_24HZ_3D_FP;
            else
                hdmi_mode = get_suitable_hdmi_mode();
            ctx->display_width[1] = get_width_from_mode(hdmi_mode);
            ctx->display_height[1] = get_height_from_mode(hdmi_mode);
            ctx->out_type[1] = DISP_OUTPUT_TYPE_HDMI;
            ctx->out_mode[1] = hdmi_mode;

			ctx->hdmi_valid_width = get_valid_width_from_mode(hdmi_mode);
			ctx->hdmi_valid_height = get_valid_height_from_mode(hdmi_mode);
            
            arg[0] = 1;
            arg[1] = hdmi_mode;
            ioctl(ctx->disp_fp, DISP_CMD_HDMI_SET_MODE, (unsigned long)arg);

            arg[0] = 1;
            ioctl(ctx->disp_fp, DISP_CMD_HDMI_ON, (unsigned long)arg);

            ALOGD( "####hdmi plug in, out_type:%d, out_mode:%d", ctx->out_type[1],ctx->out_mode[1]);
        }
        else
        {
            arg[0] = 1;
            ioctl(ctx->disp_fp, DISP_CMD_HDMI_OFF, (unsigned long)arg);
            ALOGD( "####hdmi plug out");
        }

        ctx->psHwcProcs->hotplug(ctx->psHwcProcs, HWC_DISPLAY_EXTERNAL, ctx->hdmi_hpd);

        ctx->hdmi_hpd_active = ctx->hdmi_hpd;
        
        return 1;
    }

    return 0;
}
예제 #2
0
static int hwc_vga_switch(int vga_hpd)
{
    SUNXI_hwcdev_context_t *ctx = &gSunxiHwcDevice;

    if(ctx->psHwcProcs && ctx->psHwcProcs->hotplug)
    {
        unsigned long arg[4]={0};

        if(vga_hpd)
        {
            __disp_vga_mode_t vga_mode = ctx->vga_mode;

            ctx->display_width[1] = get_width_from_mode(vga_mode);
            ctx->display_height[1] = get_height_from_mode(vga_mode);
            ctx->out_type[1] = DISP_OUTPUT_TYPE_VGA;
            ctx->out_mode[1] = vga_mode;

            //ctx->hdmi_valid_width = get_valid_width_from_mode(tv_mode);
            //ctx->hdmi_valid_height = get_valid_height_from_mode(tv_mode);

            arg[0] = 1;
            arg[1] = vga_mode;
            ioctl(ctx->disp_fp, DISP_CMD_VGA_SET_MODE, (unsigned long)arg);

            arg[0] = 1;
            ioctl(ctx->disp_fp, DISP_CMD_VGA_ON, (unsigned long)arg);

            ALOGD( "####vga plug in, out_type:%d, out_mode:%d", ctx->out_type[1],ctx->out_mode[1]);
        }
        else
        {
            arg[0] = 1;
            ioctl(ctx->disp_fp, DISP_CMD_VGA_OFF, (unsigned long)arg);
            ALOGD( "####vga plug out");
        }

        ctx->psHwcProcs->hotplug(ctx->psHwcProcs, HWC_DISPLAY_EXTERNAL, vga_hpd);

        ctx->vga_hpd_active = vga_hpd;

        return 1;
    }

    return 0;
}
SUNXI_hwcdev_context_t* hwcdev_create_device(void)
{
    SUNXI_hwcdev_context_t *ctx = &gSunxiHwcDevice;
    size_t i,disp;
    unsigned long arg[4]={0};
    int sw_fd;
    __disp_tv_mode_t hdmi_mode;
    unsigned int ui32Default;
    void *pvHintState;
    unsigned int ui32HALHdmiMode;
    FILE *srcFp;

    memset(ctx, 0, sizeof(SUNXI_hwcdev_context_t));

    for(disp = 0; disp < 2; disp++)
    {
    	ctx->pipes[disp] = (SUNXI_hwcdev_pipe_t *)calloc(DISPLAY_MAX_LAYER_NUM, sizeof(SUNXI_hwcdev_pipe_t));
    	ctx->pipeCount[disp] = DISPLAY_MAX_LAYER_NUM;
    	for (i = 0; i < ctx->pipeCount[disp]; i++)
    	{
    		ctx->pipes[disp][i].pipeNo = i;
    	}
	}

    ctx->disp_fp = open("/dev/disp", O_RDWR);
    if (ctx->disp_fp < 0)
    {
        ALOGD( "Failed to open disp device, ret:%d, errno: %d\n", ctx->disp_fp, errno);
    }
    
    ctx->fb_fp[0] = open("/dev/graphics/fb0", O_RDWR);
    if (ctx->fb_fp[0] < 0)
    {
        ALOGD( "Failed to open fb0 device, ret:%d, errno:%d\n", ctx->fb_fp[0], errno);
    }
    
	arg[0] = 0;

#ifdef __LECACY_USED__ 
	ctx->app_width = ioctl(ctx->disp_fp, DISP_CMD_SCN_GET_WIDTH, (unsigned long)arg);
	ctx->app_height = ioctl(ctx->disp_fp,DISP_CMD_SCN_GET_HEIGHT, (unsigned long)arg);

	arg[0] = 0;
	arg[1] = DISP_LAYER_WORK_MODE_NORMAL;
	ioctl(ctx->disp_fp, DISP_CMD_LAYER_REQUEST, (unsigned long)arg);

	arg[0] = 0;
	arg[1] = DISP_LAYER_WORK_MODE_NORMAL;
	ioctl(ctx->disp_fp, DISP_CMD_LAYER_REQUEST, (unsigned long)arg);

	arg[0] = 0;
	arg[1] = DISP_LAYER_WORK_MODE_NORMAL;
	ioctl(ctx->disp_fp, DISP_CMD_LAYER_REQUEST, (unsigned long)arg);

/*
	arg[0] = 1;
	arg[1] = DISP_LAYER_WORK_MODE_NORMAL;
	ioctl(ctx->disp_fp, DISP_CMD_LAYER_REQUEST, (unsigned long)arg);

	arg[0] = 1;
	arg[1] = DISP_LAYER_WORK_MODE_NORMAL;
	ioctl(ctx->disp_fp, DISP_CMD_LAYER_REQUEST, (unsigned long)arg);

	arg[0] = 1;
	arg[1] = DISP_LAYER_WORK_MODE_NORMAL;
	ioctl(ctx->disp_fp, DISP_CMD_LAYER_REQUEST, (unsigned long)arg);

	arg[0] = 1;
	arg[1] = DISP_LAYER_WORK_MODE_NORMAL;
	ioctl(ctx->disp_fp, DISP_CMD_LAYER_REQUEST, (unsigned long)arg);
*/
#else
					
	ctx->app_width = ioctl(ctx->disp_fp, DISP_CMD_GET_SCN_WIDTH, (unsigned long)arg);
	ctx->app_height = ioctl(ctx->disp_fp,DISP_CMD_GET_SCN_HEIGHT, (unsigned long)arg);
#endif
    sw_fd = open("/sys/class/switch/hdmi/state", O_RDONLY);
    if (sw_fd) 
    {
        char val;
        if (read(sw_fd, &val, 1) == 1 && val == '1') 
        {
            ctx->hdmi_hpd = 1;
            ALOGD( "####init hdmi_plug:%d", ctx->hdmi_hpd);
        }
    }
    
    ctx->hint_hdmi_mode = 255;//4;

    ctx->display_width[0] = ctx->app_width;
    ctx->display_height[0] = ctx->app_height;
    ctx->out_type[0] = DISP_OUTPUT_TYPE_LCD;
    ctx->out_mode[0] = 0;
    ctx->display_persent[0] = 100;
    
    hdmi_mode = get_suitable_hdmi_mode();
    ctx->display_width[1] = get_width_from_mode(hdmi_mode);
    ctx->display_height[1] = get_height_from_mode(hdmi_mode);
    ctx->out_type[1] = DISP_OUTPUT_TYPE_HDMI;
    ctx->out_mode[1] = hdmi_mode;
    ctx->display_persent[1] = 96;

    ctx->cur_3d_mode[0] = DISPLAY_2D_ORIGINAL;
    ctx->cur_3d_mode[1] = DISPLAY_2D_ORIGINAL;

    pthread_create(&ctx->sVsyncThread, NULL, VsyncThreadWrapper, ctx);

#ifdef HWC_FPS_REPORT
        ctx->bReportFpsEnabled = 0; 
#endif /* HWC_FPS_REPORT */	
	return (SUNXI_hwcdev_context_t*)ctx;
}