]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
fbdev: sh_mipi_dsi: Implement sh_mobile_lcdc_entity interface
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sun, 11 Sep 2011 16:27:50 +0000 (18:27 +0200)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Mon, 12 Mar 2012 21:40:45 +0000 (22:40 +0100)
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
drivers/video/sh_mipi_dsi.c

index 05151b82f40f9867bd36ea5579610a5e6ae82af4..58744fee230e326fc3465bca4a0f2990a6105073 100644 (file)
@@ -24,6 +24,8 @@
 #include <video/sh_mipi_dsi.h>
 #include <video/sh_mobile_lcdc.h>
 
+#include "sh_mobile_lcdcfb.h"
+
 #define SYSCTRL                0x0000
 #define SYSCONF                0x0004
 #define TIMSET         0x0008
@@ -50,6 +52,8 @@
 #define MAX_SH_MIPI_DSI 2
 
 struct sh_mipi {
+       struct sh_mobile_lcdc_entity entity;
+
        void __iomem    *base;
        void __iomem    *linkbase;
        struct clk      *dsit_clk;
@@ -60,6 +64,8 @@ struct sh_mipi {
        void    (*next_display_off)(void *board_data);
 };
 
+#define to_sh_mipi(e)  container_of(e, struct sh_mipi, entity)
+
 static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI];
 
 /* Protect the above array */
@@ -120,7 +126,7 @@ static void sh_mipi_dsi_enable(struct sh_mipi *mipi, bool enable)
 
 static void sh_mipi_shutdown(struct platform_device *pdev)
 {
-       struct sh_mipi *mipi = platform_get_drvdata(pdev);
+       struct sh_mipi *mipi = to_sh_mipi(platform_get_drvdata(pdev));
 
        sh_mipi_dsi_enable(mipi, false);
 }
@@ -392,9 +398,10 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
        return 0;
 }
 
-static void mipi_display_on(void *arg, struct fb_info *info)
+static int __mipi_display_on(struct sh_mobile_lcdc_entity *entity,
+                            struct fb_info *info)
 {
-       struct sh_mipi *mipi = arg;
+       struct sh_mipi *mipi = to_sh_mipi(entity);
        struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data;
        int ret;
 
@@ -410,24 +417,34 @@ static void mipi_display_on(void *arg, struct fb_info *info)
 
        sh_mipi_dsi_enable(mipi, true);
 
-       if (mipi->next_display_on)
-               mipi->next_display_on(mipi->next_board_data, info);
-
-       return;
+       return 0;
 
 mipi_display_on_fail1:
        pm_runtime_put_sync(&mipi->pdev->dev);
 mipi_display_on_fail2:
        pdata->set_dot_clock(mipi->pdev, mipi->base, 0);
+
+       return ret;
 }
 
-static void mipi_display_off(void *arg)
+static void mipi_display_on(void *arg, struct fb_info *info)
 {
-       struct sh_mipi *mipi = arg;
-       struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data;
+       struct sh_mobile_lcdc_entity *entity = arg;
+       struct sh_mipi *mipi = to_sh_mipi(entity);
+       int ret;
 
-       if (mipi->next_display_off)
-               mipi->next_display_off(mipi->next_board_data);
+       ret = __mipi_display_on(entity, info);
+       if (ret < 0)
+               return;
+
+       if (mipi->next_display_on)
+               mipi->next_display_on(mipi->next_board_data, info);
+}
+
+static void __mipi_display_off(struct sh_mobile_lcdc_entity *entity)
+{
+       struct sh_mipi *mipi = to_sh_mipi(entity);
+       struct sh_mipi_dsi_info *pdata = mipi->pdev->dev.platform_data;
 
        sh_mipi_dsi_enable(mipi, false);
 
@@ -436,6 +453,22 @@ static void mipi_display_off(void *arg)
        pm_runtime_put_sync(&mipi->pdev->dev);
 }
 
+static void mipi_display_off(void *arg)
+{
+       struct sh_mobile_lcdc_entity *entity = arg;
+       struct sh_mipi *mipi = to_sh_mipi(entity);
+
+       if (mipi->next_display_off)
+               mipi->next_display_off(mipi->next_board_data);
+
+       __mipi_display_off(entity);
+}
+
+static const struct sh_mobile_lcdc_entity_ops mipi_ops = {
+       .display_on = __mipi_display_on,
+       .display_off = __mipi_display_off,
+};
+
 static int __init sh_mipi_probe(struct platform_device *pdev)
 {
        struct sh_mipi *mipi;
@@ -467,6 +500,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
                goto ealloc;
        }
 
+       mipi->entity.owner = THIS_MODULE;
+       mipi->entity.ops = &mipi_ops;
+
        if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
                dev_err(&pdev->dev, "MIPI register region already claimed\n");
                ret = -EBUSY;
@@ -521,7 +557,7 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
        pm_runtime_resume(&pdev->dev);
 
        mutex_unlock(&array_lock);
-       platform_set_drvdata(pdev, mipi);
+       platform_set_drvdata(pdev, &mipi->entity);
 
        /* Save original LCDC callbacks */
        mipi->next_board_data = pdata->lcd_chan->board_cfg.board_data;
@@ -529,7 +565,7 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
        mipi->next_display_off = pdata->lcd_chan->board_cfg.display_off;
 
        /* Set up LCDC callbacks */
-       pdata->lcd_chan->board_cfg.board_data = mipi;
+       pdata->lcd_chan->board_cfg.board_data = &mipi->entity;
        pdata->lcd_chan->board_cfg.display_on = mipi_display_on;
        pdata->lcd_chan->board_cfg.display_off = mipi_display_off;
        pdata->lcd_chan->board_cfg.owner = THIS_MODULE;
@@ -561,7 +597,7 @@ static int __exit sh_mipi_remove(struct platform_device *pdev)
        struct sh_mipi_dsi_info *pdata = pdev->dev.platform_data;
        struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        struct resource *res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-       struct sh_mipi *mipi = platform_get_drvdata(pdev);
+       struct sh_mipi *mipi = to_sh_mipi(platform_get_drvdata(pdev));
        int i, ret;
 
        mutex_lock(&array_lock);