gfx: display: make tc35876x independent of tmd vid driver
authorJani Nikula <jani.nikula@intel.com>
Thu, 5 Jan 2012 13:35:39 +0000 (15:35 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Jul 2012 09:29:28 +0000 (12:29 +0300)
The TC35876X driver used to be bolted on the TMD panel driver with some
ifs. Make it a more independent driver instead.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Acked-by: Pauli Nieminen <pauli.nieminen@linux.intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
drivers/staging/mrst/drv/mdfld_output.c
drivers/staging/mrst/drv/tc35876x-dsi-lvds.c
drivers/staging/mrst/drv/tc35876x-dsi-lvds.h
drivers/staging/mrst/drv/tmd_vid.c

index 0ae31f6..562e00a 100644 (file)
@@ -110,8 +110,9 @@ void init_panel(struct drm_device* dev, int mipi_pipe, enum panel_type p_type)
                mdfld_dsi_output_init(dev, mipi_pipe, NULL, p_cmd_funcs, NULL);
                break;
        case TC35876X:
-               tc35876x_bridge_init();
-               /* fallthrough */
+               tc35876x_init(dev, p_vid_funcs);
+               mdfld_dsi_output_init(dev, mipi_pipe, NULL, NULL, p_vid_funcs);
+               break;
        case TMD_VID:
                tmd_vid_init(dev, p_vid_funcs);
                mdfld_dsi_output_init(dev, mipi_pipe, NULL, NULL, p_vid_funcs);
index 869bb06..636e91d 100644 (file)
@@ -445,12 +445,15 @@ void tc35876x_toshiba_bridge_panel_on(void)
                gpio_set_value_cansleep(pdata->gpio_panel_bl_en, 1);
 }
 
-void tc35876x_bridge_get_display_params(struct drm_display_mode *mode)
+static struct drm_display_mode *tc35876x_get_config_mode(struct drm_device *dev)
 {
-       if (WARN(!tc35876x_client, "%s called before probe", __func__))
-               return;
+       struct drm_display_mode *mode;
 
-       dev_dbg(&tc35876x_client->dev, "%s\n", __func__);
+       dev_dbg(&dev->pdev->dev, "%s\n", __func__);
+
+       mode = kzalloc(sizeof(*mode), GFP_KERNEL);
+       if (!mode)
+               return NULL;
 
        /* FIXME: do this properly. */
        mode->hdisplay = 1280;
@@ -463,22 +466,29 @@ void tc35876x_bridge_get_display_params(struct drm_display_mode *mode)
        mode->vtotal = 838;
        mode->clock = 33324;
 
-       dev_info(&tc35876x_client->dev, "hdisplay(w) = %d\n", mode->hdisplay);
-       dev_info(&tc35876x_client->dev, "vdisplay(h) = %d\n", mode->vdisplay);
-       dev_info(&tc35876x_client->dev, "HSS = %d\n", mode->hsync_start);
-       dev_info(&tc35876x_client->dev, "HSE = %d\n", mode->hsync_end);
-       dev_info(&tc35876x_client->dev, "htotal = %d\n", mode->htotal);
-       dev_info(&tc35876x_client->dev, "VSS = %d\n", mode->vsync_start);
-       dev_info(&tc35876x_client->dev, "VSE = %d\n", mode->vsync_end);
-       dev_info(&tc35876x_client->dev, "vtotal = %d\n", mode->vtotal);
-       dev_info(&tc35876x_client->dev, "clock = %d\n", mode->clock);
+       dev_info(&dev->pdev->dev, "hdisplay(w) = %d\n", mode->hdisplay);
+       dev_info(&dev->pdev->dev, "vdisplay(h) = %d\n", mode->vdisplay);
+       dev_info(&dev->pdev->dev, "HSS = %d\n", mode->hsync_start);
+       dev_info(&dev->pdev->dev, "HSE = %d\n", mode->hsync_end);
+       dev_info(&dev->pdev->dev, "htotal = %d\n", mode->htotal);
+       dev_info(&dev->pdev->dev, "VSS = %d\n", mode->vsync_start);
+       dev_info(&dev->pdev->dev, "VSE = %d\n", mode->vsync_end);
+       dev_info(&dev->pdev->dev, "vtotal = %d\n", mode->vtotal);
+       dev_info(&dev->pdev->dev, "clock = %d\n", mode->clock);
+
+       drm_mode_set_name(mode);
+       drm_mode_set_crtcinfo(mode, 0);
+
+       mode->type |= DRM_MODE_TYPE_PREFERRED;
+
+       return mode;
 }
 
 /* DV1 Active area 216.96 x 135.6 mm */
 #define DV1_PANEL_WIDTH 217
 #define DV1_PANEL_HEIGHT 136
 
-int tc35876x_bridge_get_panel_info(struct drm_device *dev, int pipe,
+static int tc35876x_get_panel_info(struct drm_device *dev, int pipe,
                                struct panel_info *pi)
 {
        if (!dev || !pi)
@@ -637,23 +647,47 @@ static int cmi_lcd_hack_create_device(void)
        return 0;
 }
 
-int tc35876x_bridge_init(void)
+static const struct drm_encoder_helper_funcs tc35876x_encoder_helper_funcs = {
+       .dpms = mdfld_dsi_dpi_dpms,
+       .mode_fixup = mdfld_dsi_dpi_mode_fixup,
+       .prepare = mdfld_dsi_dpi_prepare,
+       .mode_set = mdfld_dsi_dpi_mode_set,
+       .commit = mdfld_dsi_dpi_commit,
+};
+
+static const struct drm_encoder_funcs tc35876x_encoder_funcs = {
+       .destroy = drm_encoder_cleanup,
+};
+
+void tc35876x_init(struct drm_device *dev, struct panel_funcs *pf)
 {
        int r;
 
-       pr_debug("%s\n", __func__);
+       dev_dbg(&dev->pdev->dev, "%s\n", __func__);
+
+       memset(pf, 0, sizeof(*pf));
+
+       pf->encoder_funcs = &tc35876x_encoder_funcs;
+       pf->encoder_helper_funcs = &tc35876x_encoder_helper_funcs;
+       pf->get_config_mode = tc35876x_get_config_mode;
+       pf->get_panel_info = tc35876x_get_panel_info;
 
        cmi_lcd_hack_create_device();
 
        r = i2c_add_driver(&cmi_lcd_i2c_driver);
        if (r < 0)
-               pr_err("%s: i2c_add_driver() for %s failed (%d)\n",
-                      __func__, cmi_lcd_i2c_driver.driver.name, r);
+               dev_err(&dev->pdev->dev,
+                       "%s: i2c_add_driver() for %s failed (%d)\n",
+                       __func__, cmi_lcd_i2c_driver.driver.name, r);
 
-       return i2c_add_driver(&tc35876x_bridge_i2c_driver);
+       r = i2c_add_driver(&tc35876x_bridge_i2c_driver);
+       if (r < 0)
+               dev_err(&dev->pdev->dev,
+                       "%s: i2c_add_driver() for %s failed (%d)\n",
+                       __func__, tc35876x_bridge_i2c_driver.driver.name, r);
 }
 
-void tc35876x_bridge_exit(void)
+void tc35876x_exit(void)
 {
        pr_debug("%s\n", __func__);
 
index 1e445c2..fe6c4dd 100644 (file)
@@ -29,10 +29,7 @@ void tc35876x_set_bridge_reset_state(int state);
 void tc35876x_configure_lvds_bridge(struct drm_device *dev);
 void tc35876x_toshiba_bridge_panel_off(void);
 void tc35876x_toshiba_bridge_panel_on(void);
-void tc35876x_bridge_get_display_params(struct drm_display_mode *mode);
-int tc35876x_bridge_get_panel_info(struct drm_device *dev, int pipe,
-                               struct panel_info *pi);
-int tc35876x_bridge_init(void);
-void tc35876x_bridge_exit(void);
+void tc35876x_init(struct drm_device *dev, struct panel_funcs *pf);
+void tc35876x_exit(void);
 
 #endif /*__MDFLD_DSI_LVDS_BRIDGE_H__*/
index c5e425e..2bf1065 100644 (file)
@@ -30,7 +30,6 @@
 #include "displays/tmd_vid.h"
 #include "mdfld_dsi_dpi.h"
 #include "mdfld_dsi_pkg_sender.h"
-#include "tc35876x-dsi-lvds.h"
 
 static struct drm_display_mode*
 tmd_vid_get_config_mode(struct drm_device* dev)
@@ -47,9 +46,7 @@ tmd_vid_get_config_mode(struct drm_device* dev)
        if (!mode)
                return NULL;
 
-       if (get_panel_type(dev, 0) == TC35876X) { /* FIXME: pipe */
-               tc35876x_bridge_get_display_params(mode);
-       } else if (use_gct) {
+       if (use_gct) {
                PSB_DEBUG_ENTRY("gct find MIPI panel. \n");
 
                mode->hdisplay = (ti->hactive_hi << 8) | ti->hactive_lo;
@@ -213,11 +210,7 @@ void tmd_vid_init(struct drm_device* dev, struct panel_funcs* p_funcs)
        p_funcs->encoder_helper_funcs = &mdfld_tpo_dpi_encoder_helper_funcs;
        p_funcs->get_config_mode = &tmd_vid_get_config_mode;
        p_funcs->update_fb = NULL;
-       if (get_panel_type(dev, 0) != TC35876X) { /* FIXME: pipe */
-               p_funcs->get_panel_info = tmd_vid_get_panel_info;
-               p_funcs->reset = mdfld_dsi_panel_reset;
-               p_funcs->drv_ic_init = mdfld_dsi_tmd_drv_ic_init;
-       } else {
-               p_funcs->get_panel_info = tc35876x_bridge_get_panel_info;
-       }
+       p_funcs->get_panel_info = tmd_vid_get_panel_info;
+       p_funcs->reset = mdfld_dsi_panel_reset;
+       p_funcs->drv_ic_init = mdfld_dsi_tmd_drv_ic_init;
 }