OMAPDSS: APPLY: Add manager set/unset output ops for omap_overlay_manager
authorArchit Taneja <archit@ti.com>
Wed, 26 Sep 2012 11:12:39 +0000 (16:42 +0530)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 26 Sep 2012 11:58:31 +0000 (14:58 +0300)
Add set_output/unset_output ops for overlay managers, these form links between
managers and outputs. Create a function in dss features which tell all the
output instances that connect to a manager, use it when a manager tries to set
an output. Add a constraint of not unsetting an output when the manager is
enabled.

Keep the omap_dss_device pointer and set/unset_device ops in overlay_manager for
now to not break things. Keep the dss feature function get_supported_displays
as it's used in some places. These will be removed later.

Signed-off-by: Archit Taneja <archit@ti.com>
drivers/video/omap2/dss/apply.c
drivers/video/omap2/dss/dss.h
drivers/video/omap2/dss/dss_features.c
drivers/video/omap2/dss/dss_features.h
drivers/video/omap2/dss/manager.c
include/video/omapdss.h

index 72f3468b07909900b4606dc251de05c6f58d2d16..3cc47265bb03e3afbdc0fe5a16f2e901c8e97ee0 100644 (file)
@@ -1174,6 +1174,76 @@ err:
        return r;
 }
 
+int dss_mgr_set_output(struct omap_overlay_manager *mgr,
+               struct omap_dss_output *output)
+{
+       int r;
+
+       mutex_lock(&apply_lock);
+
+       if (mgr->output) {
+               DSSERR("manager %s is already connected to an output\n",
+                       mgr->name);
+               r = -EINVAL;
+               goto err;
+       }
+
+       if ((mgr->supported_outputs & output->id) == 0) {
+               DSSERR("output does not support manager %s\n",
+                       mgr->name);
+               r = -EINVAL;
+               goto err;
+       }
+
+       output->manager = mgr;
+       mgr->output = output;
+
+       mutex_unlock(&apply_lock);
+
+       return 0;
+err:
+       mutex_unlock(&apply_lock);
+       return r;
+}
+
+int dss_mgr_unset_output(struct omap_overlay_manager *mgr)
+{
+       int r;
+       struct mgr_priv_data *mp = get_mgr_priv(mgr);
+       unsigned long flags;
+
+       mutex_lock(&apply_lock);
+
+       if (!mgr->output) {
+               DSSERR("failed to unset output, output not set\n");
+               r = -EINVAL;
+               goto err;
+       }
+
+       spin_lock_irqsave(&data_lock, flags);
+
+       if (mp->enabled) {
+               DSSERR("output can't be unset when manager is enabled\n");
+               r = -EINVAL;
+               goto err1;
+       }
+
+       spin_unlock_irqrestore(&data_lock, flags);
+
+       mgr->output->manager = NULL;
+       mgr->output = NULL;
+
+       mutex_unlock(&apply_lock);
+
+       return 0;
+err1:
+       spin_unlock_irqrestore(&data_lock, flags);
+err:
+       mutex_unlock(&apply_lock);
+
+       return r;
+}
+
 static void dss_apply_mgr_timings(struct omap_overlay_manager *mgr,
                const struct omap_video_timings *timings)
 {
index aecd3bea2e63e6091ba51333cd12b10250cdbe7a..b5c0df43547f49ba289c98c1ce9bb7e9716164a4 100644 (file)
@@ -209,6 +209,9 @@ void dss_mgr_get_info(struct omap_overlay_manager *mgr,
 int dss_mgr_set_device(struct omap_overlay_manager *mgr,
                struct omap_dss_device *dssdev);
 int dss_mgr_unset_device(struct omap_overlay_manager *mgr);
+int dss_mgr_set_output(struct omap_overlay_manager *mgr,
+               struct omap_dss_output *output);
+int dss_mgr_unset_output(struct omap_overlay_manager *mgr);
 void dss_mgr_set_timings(struct omap_overlay_manager *mgr,
                const struct omap_video_timings *timings);
 void dss_mgr_set_lcd_config(struct omap_overlay_manager *mgr,
index 406913949e2c49e7c1c730e06d80d80b9bd2f6a0..bfe7fc7b8593488e43e6bd9578986751a2239b9e 100644 (file)
@@ -47,6 +47,7 @@ struct omap_dss_features {
        const int num_mgrs;
        const int num_ovls;
        const enum omap_display_type *supported_displays;
+       const enum omap_dss_output_id *supported_outputs;
        const enum omap_color_mode *supported_color_modes;
        const enum omap_overlay_caps *overlay_caps;
        const char * const *clksrc_names;
@@ -172,6 +173,63 @@ static const enum omap_display_type omap5_dss_supported_displays[] = {
        OMAP_DISPLAY_TYPE_DSI,
 };
 
+static const enum omap_dss_output_id omap2_dss_supported_outputs[] = {
+       /* OMAP_DSS_CHANNEL_LCD */
+       OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI,
+
+       /* OMAP_DSS_CHANNEL_DIGIT */
+       OMAP_DSS_OUTPUT_VENC,
+};
+
+static const enum omap_dss_output_id omap3430_dss_supported_outputs[] = {
+       /* OMAP_DSS_CHANNEL_LCD */
+       OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
+       OMAP_DSS_OUTPUT_SDI | OMAP_DSS_OUTPUT_DSI1,
+
+       /* OMAP_DSS_CHANNEL_DIGIT */
+       OMAP_DSS_OUTPUT_VENC,
+};
+
+static const enum omap_dss_output_id omap3630_dss_supported_outputs[] = {
+       /* OMAP_DSS_CHANNEL_LCD */
+       OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
+       OMAP_DSS_OUTPUT_DSI1,
+
+       /* OMAP_DSS_CHANNEL_DIGIT */
+       OMAP_DSS_OUTPUT_VENC,
+};
+
+static const enum omap_dss_output_id omap4_dss_supported_outputs[] = {
+       /* OMAP_DSS_CHANNEL_LCD */
+       OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
+       OMAP_DSS_OUTPUT_DSI1,
+
+       /* OMAP_DSS_CHANNEL_DIGIT */
+       OMAP_DSS_OUTPUT_VENC | OMAP_DSS_OUTPUT_HDMI |
+       OMAP_DSS_OUTPUT_DPI,
+
+       /* OMAP_DSS_CHANNEL_LCD2 */
+       OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
+       OMAP_DSS_OUTPUT_DSI2,
+};
+
+static const enum omap_dss_output_id omap5_dss_supported_outputs[] = {
+       /* OMAP_DSS_CHANNEL_LCD */
+       OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
+       OMAP_DSS_OUTPUT_DSI1 | OMAP_DSS_OUTPUT_DSI2,
+
+       /* OMAP_DSS_CHANNEL_DIGIT */
+       OMAP_DSS_OUTPUT_HDMI | OMAP_DSS_OUTPUT_DPI,
+
+       /* OMAP_DSS_CHANNEL_LCD2 */
+       OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
+       OMAP_DSS_OUTPUT_DSI1,
+
+       /* OMAP_DSS_CHANNEL_LCD3 */
+       OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
+       OMAP_DSS_OUTPUT_DSI2,
+};
+
 static const enum omap_color_mode omap2_dss_supported_color_modes[] = {
        /* OMAP_DSS_GFX */
        OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
@@ -554,6 +612,7 @@ static const struct omap_dss_features omap2_dss_features = {
        .num_mgrs = 2,
        .num_ovls = 3,
        .supported_displays = omap2_dss_supported_displays,
+       .supported_outputs = omap2_dss_supported_outputs,
        .supported_color_modes = omap2_dss_supported_color_modes,
        .overlay_caps = omap2_dss_overlay_caps,
        .clksrc_names = omap2_dss_clk_source_names,
@@ -574,6 +633,7 @@ static const struct omap_dss_features omap3430_dss_features = {
        .num_mgrs = 2,
        .num_ovls = 3,
        .supported_displays = omap3430_dss_supported_displays,
+       .supported_outputs = omap3430_dss_supported_outputs,
        .supported_color_modes = omap3_dss_supported_color_modes,
        .overlay_caps = omap3430_dss_overlay_caps,
        .clksrc_names = omap3_dss_clk_source_names,
@@ -597,6 +657,7 @@ static const struct omap_dss_features am35xx_dss_features = {
        .num_mgrs = 2,
        .num_ovls = 3,
        .supported_displays = omap3430_dss_supported_displays,
+       .supported_outputs = omap3430_dss_supported_outputs,
        .supported_color_modes = omap3_dss_supported_color_modes,
        .overlay_caps = omap3430_dss_overlay_caps,
        .clksrc_names = omap3_dss_clk_source_names,
@@ -616,6 +677,7 @@ static const struct omap_dss_features omap3630_dss_features = {
        .num_mgrs = 2,
        .num_ovls = 3,
        .supported_displays = omap3630_dss_supported_displays,
+       .supported_outputs = omap3630_dss_supported_outputs,
        .supported_color_modes = omap3_dss_supported_color_modes,
        .overlay_caps = omap3630_dss_overlay_caps,
        .clksrc_names = omap3_dss_clk_source_names,
@@ -637,6 +699,7 @@ static const struct omap_dss_features omap4430_es1_0_dss_features  = {
        .num_mgrs = 3,
        .num_ovls = 4,
        .supported_displays = omap4_dss_supported_displays,
+       .supported_outputs = omap4_dss_supported_outputs,
        .supported_color_modes = omap4_dss_supported_color_modes,
        .overlay_caps = omap4_dss_overlay_caps,
        .clksrc_names = omap4_dss_clk_source_names,
@@ -657,6 +720,7 @@ static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = {
        .num_mgrs = 3,
        .num_ovls = 4,
        .supported_displays = omap4_dss_supported_displays,
+       .supported_outputs = omap4_dss_supported_outputs,
        .supported_color_modes = omap4_dss_supported_color_modes,
        .overlay_caps = omap4_dss_overlay_caps,
        .clksrc_names = omap4_dss_clk_source_names,
@@ -677,6 +741,7 @@ static const struct omap_dss_features omap4_dss_features = {
        .num_mgrs = 3,
        .num_ovls = 4,
        .supported_displays = omap4_dss_supported_displays,
+       .supported_outputs = omap4_dss_supported_outputs,
        .supported_color_modes = omap4_dss_supported_color_modes,
        .overlay_caps = omap4_dss_overlay_caps,
        .clksrc_names = omap4_dss_clk_source_names,
@@ -697,6 +762,7 @@ static const struct omap_dss_features omap5_dss_features = {
        .num_mgrs = 3,
        .num_ovls = 4,
        .supported_displays = omap5_dss_supported_displays,
+       .supported_outputs = omap5_dss_supported_outputs,
        .supported_color_modes = omap4_dss_supported_color_modes,
        .overlay_caps = omap4_dss_overlay_caps,
        .clksrc_names = omap5_dss_clk_source_names,
@@ -766,6 +832,11 @@ enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel
        return omap_current_dss_features->supported_displays[channel];
 }
 
+enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel)
+{
+       return omap_current_dss_features->supported_outputs[channel];
+}
+
 enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane)
 {
        return omap_current_dss_features->supported_color_modes[plane];
index aacad863fa2208ef4d664f68d37222d76a79d4ee..89df2aa860d4c0de75148bfb1e93a138fa0d20c0 100644 (file)
@@ -108,6 +108,7 @@ int dss_feat_get_num_ovls(void);
 unsigned long dss_feat_get_param_min(enum dss_range_param param);
 unsigned long dss_feat_get_param_max(enum dss_range_param param);
 enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel);
+enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel);
 enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane);
 enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane plane);
 bool dss_feat_color_mode_supported(enum omap_plane plane,
index 383314f222b0692e9ce2d5de272292e5093f08e8..92a2585d04b2d515231463e61c7dc6f3aa216171 100644 (file)
@@ -95,6 +95,8 @@ int dss_init_overlay_managers(struct platform_device *pdev)
 
                mgr->set_device = &dss_mgr_set_device;
                mgr->unset_device = &dss_mgr_unset_device;
+               mgr->set_output = &dss_mgr_set_output;
+               mgr->unset_output = &dss_mgr_unset_output;
                mgr->apply = &omap_dss_mgr_apply;
                mgr->set_manager_info = &dss_mgr_set_info;
                mgr->get_manager_info = &dss_mgr_get_info;
@@ -104,6 +106,8 @@ int dss_init_overlay_managers(struct platform_device *pdev)
                mgr->caps = 0;
                mgr->supported_displays =
                        dss_feat_get_supported_displays(mgr->id);
+               mgr->supported_outputs =
+                       dss_feat_get_supported_outputs(mgr->id);
 
                INIT_LIST_HEAD(&mgr->overlays);
 
index 6d08cf55e5e242996458753c53f49111320fe680..d8fd1c85fc87f965212942dbf763ce82bc2dea0d 100644 (file)
@@ -459,9 +459,11 @@ struct omap_overlay_manager {
        enum omap_overlay_manager_caps caps;
        struct list_head overlays;
        enum omap_display_type supported_displays;
+       enum omap_dss_output_id supported_outputs;
 
        /* dynamic fields */
        struct omap_dss_device *device;
+       struct omap_dss_output *output;
 
        /*
         * The following functions do not block:
@@ -477,6 +479,9 @@ struct omap_overlay_manager {
        int (*set_device)(struct omap_overlay_manager *mgr,
                struct omap_dss_device *dssdev);
        int (*unset_device)(struct omap_overlay_manager *mgr);
+       int (*set_output)(struct omap_overlay_manager *mgr,
+               struct omap_dss_output *output);
+       int (*unset_output)(struct omap_overlay_manager *mgr);
 
        int (*set_manager_info)(struct omap_overlay_manager *mgr,
                        struct omap_overlay_manager_info *info);