/*
 * ip7500av_vdac_init
 *	Initializes the video DAC via I2C
 *
 * Equivalent mode line: 720x480p = 27 Mhz, 720 736 800 858 480 484 492 525
 */
static int __init ip7500av_vdac_init(void)
{
	return adv7393_init(0, 0x2B, GPIO_RF_6);
}
/*
 * ip7500iap_init_offboard_video
 */
static int __init ip7500iap_init_offboard_video(struct lcd_adapter_info *info)
{
	struct i2c_adapter *adap;

#ifdef CONFIG_FB_UBICOM32
	/*
	 * If we are autodetect then bring up the display now
	 */
#ifdef CONFIG_DISPLAY_AUTODETECT
	/*
	 * Check for 8000-0210 PPI-TFP410
	 */
	if (info->panel_type == 12) {
		tfp410_init(0, 0x38, GPIO_RD_1);
	}

	/*
	 * Check for 8000-0310 PPI-ADV7393
	 */
	if (info->panel_type == 11) {
		adv7393_init(0, 0x2B, GPIO_RD_1);
	}

	/*
	 * Use the VDC for devices which are HV/TCON
	 */
	if (info->driver_type[0] & (LCD_ADAPTER_DTYPE0_HV | LCD_ADAPTER_DTYPE0_TCON | LCD_ADAPTER_DTYPE0_DE)) {
		struct ubicom32fb_platform_data *pd = &ip7500iap_ubicom32fb_platform_data;

		memset(pd, 0, sizeof(*pd));

		if (info->driver_type[0] & LCD_ADAPTER_DTYPE0_HV) {
			pd->mode = UBICOM32FB_MODE_SYNC;
		} else if (info->driver_type[0] & LCD_ADAPTER_DTYPE0_TCON) {
			pd->mode = UBICOM32FB_MODE_TCON;
		} else if (info->driver_type[0] & LCD_ADAPTER_DTYPE0_DE) {
			pd->mode = UBICOM32FB_MODE_DE;
		}

		pd->flags |= UBICOM32FB_PLATFORM_DATA_FLAG_TIMING | UBICOM32FB_PLATFORM_DATA_FLAG_MODE;
		pd->hfp = info->hfp;
		pd->hsync = info->hsync;
		pd->hbp = info->hbp;
		pd->vfp = info->vfp;
		pd->vsync = info->vsync;
		pd->vbp = info->vbp;
		pd->fclk = info->fclk;

		if (info->active_h && info->active_w) {
			pd->flags |= UBICOM32FB_PLATFORM_DATA_FLAG_DIM;
			pd->height_mm = info->active_h / 10;
			pd->width_mm = info->active_w / 10;
		}

		vdc_tio_init(pd);
	} else {
		/*
		 * Use the VFB device for other displays
		 */
		platform_device_register(&ip7500iap_vfb_device);
	}
#endif

	/*
	 * Start up the LCD Power driver if needed
	 */
	if (info->driver_type[2] & LCD_ADAPTER_DTYPE2_POWER) {
		if (info->lcd_power_pin == 38) {
			ip7500iap_lcdpower_data.vgh_gpio = GPIO_RD_2;
			platform_device_register(&ip7500iap_lcdpower_device);
		} else {
			printk(KERN_WARNING "%s: don't know about LCD power pin %u\n", __FUNCTION__, info->lcd_power_pin);
		}
	}

	/*
	 * Start up the backlight driver if needed
	 */
	if (info->backlight_type == 0x01) {
		ip7500iap_backlight_data.pwm_prescale = 7;
		platform_device_register(&ip7500iap_backlight_device);
	} else if (info->backlight_type == 0x02) {
		platform_device_register(&ip7500iap_backlight_device);
	}

	printk(KERN_INFO "%s: registering LCD Adapter Board resources\n", __FUNCTION__);

	adap = i2c_get_adapter(0);
	if (!adap) {
		printk(KERN_WARNING "%s: Failed to get i2c adapter\n", __FUNCTION__);
		return -ENODEV;
	}

	/*
	 * Offboard touch controller if needed.
	 */
	if (info->touch_addr) {
		ip7500iap_touch_i2c_board_info.addr = info->touch_addr;
		i2c_new_device(adap, &ip7500iap_touch_i2c_board_info);
	}

	i2c_put_adapter(adap);
#endif	// CONFIG_FB_UBICOM32

	return 0;
}