public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: archit taneja <archit@ti.com>
To: "Valkeinen, Tomi" <tomi.valkeinen@ti.com>
Cc: "linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [PATCH 1/3] OMAP: DSS2: Functions to request/release DSI VCs
Date: Tue, 1 Mar 2011 10:47:00 +0530	[thread overview]
Message-ID: <4D6C814C.5070307@ti.com> (raw)
In-Reply-To: <1298897516.9809.48.camel@deskari>

Hi,

On Monday 28 February 2011 06:21 PM, Valkeinen, Tomi wrote:
> On Mon, 2011-02-28 at 02:47 -0600, Taneja, Archit wrote:
>> Introduce functions which request and release VC's. This will be used in panel
>> drivers in their probes.
>>
>> omap_dsi_request_vc() takes in the pointer to the omap_dss_device, the VC_ID
>> parameter which goes into the header of the DSI packets, and returns a Virtual
>> channel number (or virtual channel register set) which it can use.
>>
>> omap_dsi_releae_vc() takes the omap_dss_device pointer and frees all VCs which
>> were used by that device.
>>
>> Initialisation of VC parameters is done in dsi_init().
>>
>> Signed-off-by: Archit Taneja<archit@ti.com>
>> ---
>>   arch/arm/plat-omap/include/plat/display.h |    3 ++
>>   drivers/video/omap2/dss/dsi.c             |   55 ++++++++++++++++++++++++++---
>>   2 files changed, 53 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/arm/plat-omap/include/plat/display.h b/arch/arm/plat-omap/include/plat/display.h
>> index d45f107..0057259 100644
>> --- a/arch/arm/plat-omap/include/plat/display.h
>> +++ b/arch/arm/plat-omap/include/plat/display.h
>> @@ -560,6 +560,9 @@ int omap_dsi_update(struct omap_dss_device *dssdev,
>>   		int channel,
>>   		u16 x, u16 y, u16 w, u16 h,
>>   		void (*callback)(int, void *), void *data);
>> +int omap_dsi_request_vc(struct omap_dss_device *dssdev, int vc_id,
>> +		int *channel);
>> +void omap_dsi_release_vc(struct omap_dss_device *dssdev);
>
> The release function is misnamed. It's actually release_all_vcs.
> However, I think the request and release functions should match:
> request/release one vc.
>
> So perhaps something like:
>
> void omap_dsi_release_vc(struct omap_dss_device *dssdev, int channel);
>
> dssdev is not really needed there, but can be used for checking validity
> of the release call.

Yes, this is better.

>
> Also, about the returned channel value. It is something that the panel
> driver should not use for anything else than to pass to DSI functions.
> Perhaps this would be a good case for typedeffing (see CodingStyle,
> chapter 5, part a). dsi_channel_t? Well, we can think about this later.
>
> In the future we could possibly encode the DSI module number in the
> channel also.
>

That's a good idea.


<snip>

>>   }
>>
>> +int omap_dsi_request_vc(struct omap_dss_device *dssdev, int vc_id, int *channel)
>> +{
>> +	int p = dsi.num_vc_used;
>> +
>> +	if (p>= 4) {
>> +		DSSERR("cannot get VC for display %s", dssdev->name);
>> +		return -EINVAL;
>> +	}
>> +
>> +	dsi.vc[p].dssdev = dssdev;
>> +	dsi.vc[p].vc_id = vc_id;
>> +	*channel = p;
>> +
>> +	dsi.num_vc_used += 1;
>> +
>> +	return 0;
>> +}
>> +EXPORT_SYMBOL(omap_dsi_request_vc);
>> +
>> +void omap_dsi_release_vc(struct omap_dss_device *dssdev)
>> +{
>> +	int i, num_vc_used_disp = 0;
>> +
>> +	for (i = 0; i<  4; i++) {
>> +		if (dsi.vc[i].dssdev == dssdev) {
>> +			dsi.vc[i].dssdev = NULL;
>> +			dsi.vc[i].vc_id = 0;
>> +			dsi.vc[i].mode = DSI_VC_MODE_L4;
>> +			num_vc_used_disp++;
>> +		}
>> +	}
>> +
>> +	dsi.num_vc_used -= num_vc_used_disp;
>> +}
>> +EXPORT_SYMBOL(omap_dsi_release_vc);
>
> I don't think these work quite right. What happens if there are two
> panel drivers, both have allocated one channel. Then the first channel
> is released. At this point num_vc_used is 1. Next request would allocate
> channel number 1, which is still in use.
>

This is quite silly of me. I think I made this thinking that the 
sequence of releases by panels will happen in opposite order to sequence 
of requests. But that won't be the case at all when the panels are 
inserted as modules

> I think the code will be cleaner and simpler if you removed num_vc_used,
> and loop through the 4 channels when allocating, trying to find a free
> one. It's just 4 iterations.
>

I will make this change.

Archit

  reply	other threads:[~2011-03-01  5:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-28  8:47 [PATCH 0/3]OMAP: DSS2: Abstract away DSI VC information from dsi panel drivers Archit Taneja
2011-02-28  8:47 ` [PATCH 1/3] OMAP: DSS2: Functions to request/release DSI VCs Archit Taneja
2011-02-28 12:51   ` Tomi Valkeinen
2011-03-01  5:17     ` archit taneja [this message]
2011-03-01  7:02       ` archit taneja
2011-02-28 14:10   ` Tomi Valkeinen
2011-03-01  5:21     ` archit taneja
2011-02-28  8:47 ` [PATCH 2/3] OMAP: DSS2: Use request / release calls in Taal for DSI Virtual Channels Archit Taneja
2011-02-28  8:47 ` [PATCH 3/3] OMAP: DSS2: Taal: Use 2 DSI Virtual Channels for Taal Archit Taneja
  -- strict thread matches above, loose matches on Subject: below --
2011-03-01 12:32 [PATCH v2 0/3]OMAP: DSS2: Abstract away DSI VC information from dsi panel drivers Archit Taneja
2011-03-01 12:32 ` [PATCH 1/3] OMAP: DSS2: Functions to request/release DSI VCs Archit Taneja
2011-03-01 13:20   ` DebBarma, Tarun Kanti
2011-03-01 13:36     ` archit taneja
2011-03-01 16:09   ` Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D6C814C.5070307@ti.com \
    --to=archit@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox