diff mbox

[18/42] drm/omap: remove crtc->mgr field

Message ID 1456161048-21240-19-git-send-email-tomi.valkeinen@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tomi Valkeinen Feb. 22, 2016, 5:10 p.m. UTC
In order to remove uses of 'struct omap_overlay_manager' from omapdrm,
this patch removes the crtc->mgr field.

To accomplish that, a new static array is added along the current
'omap_crtcs' static array, which is used to store the output device
connected to a crtc.

Optimally we'd use the struct omap_crtc to store this information, but
at the time when omap_crtc_dss_connect() is called, we don't yet have
the omap_crtc instances. This might possibly be fixed later, but for now
the static array does the job.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

Comments

Laurent Pinchart March 7, 2016, 8:52 a.m. UTC | #1
Hi Tomi,

Thank you for the patch.

On Monday 22 February 2016 19:10:24 Tomi Valkeinen wrote:
> In order to remove uses of 'struct omap_overlay_manager' from omapdrm,
> this patch removes the crtc->mgr field.
> 
> To accomplish that, a new static array is added along the current
> 'omap_crtcs' static array, which is used to store the output device
> connected to a crtc.
> 
> Optimally we'd use the struct omap_crtc to store this information, but
> at the time when omap_crtc_dss_connect() is called, we don't yet have
> the omap_crtc instances. This might possibly be fixed later, but for now
> the static array does the job.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_crtc.c | 20 +++++++-------------
>  1 file changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c
> b/drivers/gpu/drm/omapdrm/omap_crtc.c index b1ed18bf1b1b..104e70a91fd8
> 100644
> --- a/drivers/gpu/drm/omapdrm/omap_crtc.c
> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
> @@ -34,14 +34,6 @@ struct omap_crtc {
>  	const char *name;
>  	enum omap_channel channel;
> 
> -	/*
> -	 * Temporary: eventually this will go away, but it is needed
> -	 * for now to keep the output's happy.  (They only need
> -	 * mgr->id.)  Eventually this will be replaced w/ something
> -	 * more common-panel-framework-y
> -	 */
> -	struct omap_overlay_manager *mgr;
> -
>  	struct omap_video_timings timings;
> 
>  	struct omap_drm_irq vblank_irq;
> @@ -100,17 +92,20 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc)
> 
>  /* ovl-mgr-id -> crtc */
>  static struct omap_crtc *omap_crtcs[8];
> +static struct omap_dss_device *omap_crtc_output[8];

We should really move away from global structures, not adding more of them :-/ 
Could you add this to your (or my) todo list ?

>  /* we can probably ignore these until we support command-mode panels: */
>  static int omap_crtc_dss_connect(struct omap_overlay_manager *mgr,
>  		struct omap_dss_device *dst)
>  {
> -	if (mgr->output)
> +	if (omap_crtc_output[mgr->id])
>  		return -EINVAL;
> 
>  	if ((dispc_mgr_get_supported_outputs(mgr->id) & dst->id) == 0)
>  		return -EINVAL;
> 
> +	omap_crtc_output[mgr->id] = dst;
> +
>  	dst->manager = mgr;
>  	mgr->output = dst;
> 
> @@ -120,6 +115,8 @@ static int omap_crtc_dss_connect(struct
> omap_overlay_manager *mgr, static void omap_crtc_dss_disconnect(struct
> omap_overlay_manager *mgr, struct omap_dss_device *dst)
>  {
> +	omap_crtc_output[mgr->id] = NULL;
> +
>  	mgr->output->manager = NULL;
>  	mgr->output = NULL;
>  }
> @@ -138,7 +135,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc,
> bool enable) u32 framedone_irq, vsync_irq;
>  	int ret;
> 
> -	if (omap_crtc->mgr->output->output_type == OMAP_DISPLAY_TYPE_HDMI) {
> +	if (omap_crtc_output[channel]->output_type == OMAP_DISPLAY_TYPE_HDMI) {
>  		dispc_mgr_enable(channel, enable);
>  		return;
>  	}
> @@ -547,9 +544,6 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
>  	omap_crtc->error_irq.irq = omap_crtc_error_irq;
>  	omap_irq_register(dev, &omap_crtc->error_irq);
> 
> -	/* temporary: */
> -	omap_crtc->mgr = omap_dss_get_overlay_manager(channel);
> -
>  	ret = drm_crtc_init_with_planes(dev, crtc, plane, NULL,
>  					&omap_crtc_funcs, NULL);
>  	if (ret < 0) {
Tomi Valkeinen March 7, 2016, 9:19 a.m. UTC | #2
On 07/03/16 10:52, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Monday 22 February 2016 19:10:24 Tomi Valkeinen wrote:
>> In order to remove uses of 'struct omap_overlay_manager' from omapdrm,
>> this patch removes the crtc->mgr field.
>>
>> To accomplish that, a new static array is added along the current
>> 'omap_crtcs' static array, which is used to store the output device
>> connected to a crtc.
>>
>> Optimally we'd use the struct omap_crtc to store this information, but
>> at the time when omap_crtc_dss_connect() is called, we don't yet have
>> the omap_crtc instances. This might possibly be fixed later, but for now
>> the static array does the job.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> ---
>>  drivers/gpu/drm/omapdrm/omap_crtc.c | 20 +++++++-------------
>>  1 file changed, 7 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c
>> b/drivers/gpu/drm/omapdrm/omap_crtc.c index b1ed18bf1b1b..104e70a91fd8
>> 100644
>> --- a/drivers/gpu/drm/omapdrm/omap_crtc.c
>> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
>> @@ -34,14 +34,6 @@ struct omap_crtc {
>>  	const char *name;
>>  	enum omap_channel channel;
>>
>> -	/*
>> -	 * Temporary: eventually this will go away, but it is needed
>> -	 * for now to keep the output's happy.  (They only need
>> -	 * mgr->id.)  Eventually this will be replaced w/ something
>> -	 * more common-panel-framework-y
>> -	 */
>> -	struct omap_overlay_manager *mgr;
>> -
>>  	struct omap_video_timings timings;
>>
>>  	struct omap_drm_irq vblank_irq;
>> @@ -100,17 +92,20 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc)
>>
>>  /* ovl-mgr-id -> crtc */
>>  static struct omap_crtc *omap_crtcs[8];
>> +static struct omap_dss_device *omap_crtc_output[8];
> 
> We should really move away from global structures, not adding more of them :-/ 
> Could you add this to your (or my) todo list ?

Agreed.

This restructuring series was becoming quite large and confusing
already, and I didn't see an obvious solution to this problem. So, as we
already had the omap_crtcs[], I went the easy way.

 Tomi
diff mbox

Patch

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index b1ed18bf1b1b..104e70a91fd8 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -34,14 +34,6 @@  struct omap_crtc {
 	const char *name;
 	enum omap_channel channel;
 
-	/*
-	 * Temporary: eventually this will go away, but it is needed
-	 * for now to keep the output's happy.  (They only need
-	 * mgr->id.)  Eventually this will be replaced w/ something
-	 * more common-panel-framework-y
-	 */
-	struct omap_overlay_manager *mgr;
-
 	struct omap_video_timings timings;
 
 	struct omap_drm_irq vblank_irq;
@@ -100,17 +92,20 @@  int omap_crtc_wait_pending(struct drm_crtc *crtc)
 
 /* ovl-mgr-id -> crtc */
 static struct omap_crtc *omap_crtcs[8];
+static struct omap_dss_device *omap_crtc_output[8];
 
 /* we can probably ignore these until we support command-mode panels: */
 static int omap_crtc_dss_connect(struct omap_overlay_manager *mgr,
 		struct omap_dss_device *dst)
 {
-	if (mgr->output)
+	if (omap_crtc_output[mgr->id])
 		return -EINVAL;
 
 	if ((dispc_mgr_get_supported_outputs(mgr->id) & dst->id) == 0)
 		return -EINVAL;
 
+	omap_crtc_output[mgr->id] = dst;
+
 	dst->manager = mgr;
 	mgr->output = dst;
 
@@ -120,6 +115,8 @@  static int omap_crtc_dss_connect(struct omap_overlay_manager *mgr,
 static void omap_crtc_dss_disconnect(struct omap_overlay_manager *mgr,
 		struct omap_dss_device *dst)
 {
+	omap_crtc_output[mgr->id] = NULL;
+
 	mgr->output->manager = NULL;
 	mgr->output = NULL;
 }
@@ -138,7 +135,7 @@  static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 	u32 framedone_irq, vsync_irq;
 	int ret;
 
-	if (omap_crtc->mgr->output->output_type == OMAP_DISPLAY_TYPE_HDMI) {
+	if (omap_crtc_output[channel]->output_type == OMAP_DISPLAY_TYPE_HDMI) {
 		dispc_mgr_enable(channel, enable);
 		return;
 	}
@@ -547,9 +544,6 @@  struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 	omap_crtc->error_irq.irq = omap_crtc_error_irq;
 	omap_irq_register(dev, &omap_crtc->error_irq);
 
-	/* temporary: */
-	omap_crtc->mgr = omap_dss_get_overlay_manager(channel);
-
 	ret = drm_crtc_init_with_planes(dev, crtc, plane, NULL,
 					&omap_crtc_funcs, NULL);
 	if (ret < 0) {