Re: [PATCH 1/3] drm/sun4i: tcon: Reduce the scope of the LVDS error a bit

2018-03-06 Thread Maxime Ripard
Hi,

On Tue, Mar 06, 2018 at 03:38:25PM +0800, Chen-Yu Tsai wrote:
> > -   /*
> > -* This can only be made optional since we've had DT nodes
> > -* without the LVDS reset properties.
> > -*
> > -* If the property is missing, just disable LVDS, and print a
> > -* warning.
> > -*/
> > -   if (tcon->quirks->has_lvds_alt) {
> > -   tcon->lvds_pll = devm_clk_get(dev, "lvds-alt");
> > -   if (IS_ERR(tcon->lvds_pll)) {
> > -   if (PTR_ERR(tcon->lvds_pll) == -ENOENT) {
> > -   has_lvds_alt = false;
> > +   /*
> > +* This can only be made optional since we've had DT
> > +* nodes without the LVDS reset properties.
> 
> This comment doesn't match the code following it. Otherwise,

It was there before, and it was a typo. I'll send a followup patch

> Reviewed-by: Chen-Yu Tsai 

And I've applied all three patches.

Thanks!
Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com


signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 105145] vaExportSurfaceHandle interaction with surface interlaced flag prevents switching on vaapi deinterlacing dynamically

2018-03-06 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105145

--- Comment #9 from k.phil...@gmail.com ---
(In reply to Christian König from comment #8)
> (In reply to k.philipp from comment #7)
> > I did think about that, but it has the problem of breaking deinterlacing on
> > all clients that do *not* set VA_SURFACE_ATTRIB_USAGE_HINT_VPP_READ (which I
> > assume to be most) since there is - correct me if I'm wrong - at present no
> > code to un-weave a decoded frame to fields and go back to interlaced/field
> > mode, causing the initial issue in the first place.
> 
> Yeah, we can't do this without at least adding this frame to field
> conversion.
> 
> How about VA_SURFACE_ATTRIB_USAGE_HINT_EXPORT then? The VA-API hints seem to
> describe the use case instead of the effect, so that would match.
I filed a PR with libva (https://github.com/intel/libva/pull/196), we'll see
how it goes.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [RFC][PATCH 4/4 v2] drm_hwcomposer: Try to fallback if GLCompisition fails

2018-03-06 Thread John Stultz
On Tue, Feb 13, 2018 at 2:03 PM, John Stultz  wrote:
> On Tue, Feb 13, 2018 at 2:45 AM, Alexandru-Cosmin Gheorghe
>  wrote:
>> On Mon, Feb 12, 2018 at 08:43:10PM -0800, John Stultz wrote:
>>> On Wed, Jan 31, 2018 at 11:03 AM, John Stultz  
>>> wrote:
>>> > On Wed, Jan 31, 2018 at 10:51 AM, Alexandru-Cosmin Gheorghe
>>> >  wrote:
>>> >> It seems that we don't pass any explicit fences to the kernel for
>>> >> IN_FENCE_FD property. This particular line seems wrong.
>>> >>
>>> >> @@ -593,14 +594,17 @@ int
>>> >> DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp,
>>> >>else
>>> >>  rotation |= DRM_MODE_ROTATE_0;
>>> >>
>>> >> -  if (fence_fd < 0) {
>>> >> +  if (fence_fd >= 0) {
>>> >
>>> > I'll give that a whirl.
>>>
>>> So I did give that a whirl after you suggested it, but it ended up
>>> causing nothing to be displayed, and I unfortunately didn't have time
>>> right then to dig much further.
>>>
>>> Rob however re-found this issue today, and I've been digging a bit
>>> more. At least with the HiKey board, it seem the trouble is when the
>>> IN_FENCE_FD is added to the pset, the atomic commit calls start to
>>> fail. I dug in and it seems we're catching in the kernel on the  if
>>> (file->f_op != _file_fops) check in sync_file_fdget().
>>>
>>> I'm now trying to trace back to where the in fence was provided from
>>> to see what might be going wrong there.
>> I would be surprised if this fence is not created by the GPU driver.
>> But, the whole Android stack is new to me, so I might be wrong.
>
> Yes, I went digging on this last night and it ends up the utgard
> driver we use (r7p0) isn't giving us a dmabuf fence, instead we're
> getting a mali_sync_fence.
>
> There's a newer kernel driver release (r8p1), which seems to correct
> this, but it also is version tied to the binary blob, which I don't
> have a matching update for. I spent a bit of time trying to hack out
> just the dmabuf fence bits, but it rarely boots all the way and
> frequently locks the board up, so I'm probably mucking the library
> driver interface in some way.
>
> Its a well known sad song.

So, I took another stab at this tonight and actually got the dmabuf
fence handling transplanted into the older r7p0 driver we're using. So
with that and the recent fence_fd bug that has been fixed in master,
things are working *much* better. No gl_finsh() hacks needed to avoid
tearing and performance is improved nicely.

thanks
-john
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: Aspirant for GSOC 2018 for Nouveau Vulkan driver

2018-03-06 Thread Anusha Srivastava
Hi,

I am not been able to contact with mentor of this project.
Can someone else from the community help me with this ?


Regards,
Anusha Srivastava


On 3 March 2018 at 11:16, Anusha Srivastava  wrote:
> Hi Martin,
>
> Any update on this ?
> Regards,
> Anusha Srivastava
>
>
> On 28 February 2018 at 23:37, Anusha Srivastava  
> wrote:
>> Hi,
>>
>> I would like to participate in  GSOC 2018 with Xorg to contribute to
>> project "Initial Nouveau Vulkan driver'
>> I would need some help in how to get started with the same.
>>
>> Regards,
>> Anusha Srivastava
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


RE: [PATCH] drm/atomic: Add new reverse iterator over all plane state

2018-03-06 Thread S, Shirish
Hi Alex,

Have resent the V2 with R-B of Daniel.

Regards,
Shirish S


-Original Message-
From: Alex Deucher [mailto:alexdeuc...@gmail.com] 
Sent: Tuesday, March 6, 2018 11:01 PM
To: Vishwakarma, Pratik 
Cc: Daniel Vetter ; Deucher, Alexander 
; amd-...@lists.freedesktop.org; Maling list - DRI 
developers ; S, Shirish 
Subject: Re: [PATCH] drm/atomic: Add new reverse iterator over all plane state

On Tue, Mar 6, 2018 at 5:52 AM, Vishwakarma, Pratik 
 wrote:
> Hi Daniel,
>
> I have checked make htmldocs on v2 of this patch. I have attached output 
> drm-kms.html on that thread.
> No indentation issue is observed. Attached again for reference.
> Can you please provide RB on that?

How did you send the patch?  I can't get V2 to apply.  The patch is mangled.  
Please use git-send-email if you didn't before.

Alex

>
> Regards
> Pratik
>
> -Original Message-
> From: amd-gfx [mailto:amd-gfx-boun...@lists.freedesktop.org] On Behalf 
> Of Daniel Vetter
> Sent: Tuesday, March 6, 2018 3:36 PM
> To: Alex Deucher 
> Cc: Deucher, Alexander ; 
> amd-...@lists.freedesktop.org; Maling list - DRI developers 
> ; S, Shirish 
> Subject: Re: [PATCH] drm/atomic: Add new reverse iterator over all 
> plane state
>
> On Wed, Feb 28, 2018 at 09:26:26AM -0500, Alex Deucher wrote:
>> + dri-devel
>>
>>
>> On Wed, Feb 28, 2018 at 4:33 AM, S, Shirish  wrote:
>> > From: Shirish S 
>> >
>> > Add reverse iterator "for_each_oldnew_plane_in_state_reverse" to 
>> > complement "for_each_oldnew_plane_in_state" way of reading plane 
>> > states.
>> >
>> > The plane states are required to be read in reverse order for 
>> > amdgpu, as the z order convention followed in linux is opposite to 
>> > how the planes are supposed to be presented to DC engine, which is 
>> > in common to both windows and linux.
>> >
>> > Signed-off-by: Shirish S 
>> > Signed-off-by: Pratik Vishwakarma 
>
> Makes sense.
>> > ---
>> >  include/drm/drm_atomic.h | 22 ++
>> >  1 file changed, 22 insertions(+)
>> >
>> > diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h 
>> > index cf13842..b947930 100644
>> > --- a/include/drm/drm_atomic.h
>> > +++ b/include/drm/drm_atomic.h
>> > @@ -754,6 +754,28 @@ void drm_state_dump(struct drm_device *dev, struct 
>> > drm_printer *p);
>> >   (new_plane_state) = 
>> > (__state)->planes[__i].new_state, 1))
>> >
>> >  /**
>> > + * for_each_oldnew_plane_in_state_reverse - iterate over all 
>> > + planes in an atomic
>> > + * update in reverse order
>
> Are you sure this renders correctly in kernel-doc? Iirc you have to indent 
> the continuation line.
>
> Assuming this is fixed:
>
> Reviewed-by: Daniel Vetter 
>
>> > + * @__state:  drm_atomic_state pointer
>> > + * @plane:  drm_plane iteration cursor
>> > + * @old_plane_state:  drm_plane_state iteration cursor for 
>> > +the old state
>> > + * @new_plane_state:  drm_plane_state iteration cursor for 
>> > +the new state
>> > + * @__i: int iteration cursor, for macro-internal use
>> > + *
>> > + * This iterates over all planes in an atomic update in reverse 
>> > +order,
>> > + * tracking both old and  new state. This is useful in places 
>> > +where the
>> > + * state delta needs to be considered, for example in atomic check 
>> > functions.
>> > + */
>> > +#define for_each_oldnew_plane_in_state_reverse(__state, plane, 
>> > old_plane_state, new_plane_state, __i) \
>> > +   (for ((__i) = ((__state)->dev->mode_config.num_total_plane - 1);   
>> >  \
>> > +(__i) >= 0;\
>> > +(__i)--)   \
>> > +   for_each_if ((__state)->planes[__i].ptr &&  \
>> > +((plane) = (__state)->planes[__i].ptr, \
>> > + (old_plane_state) = 
>> > (__state)->planes[__i].old_state,\
>> > + (new_plane_state) = 
>> > +(__state)->planes[__i].new_state, 1)))
>> > +
>> > +/**
>> >   * for_each_old_plane_in_state - iterate over all planes in an atomic 
>> > update
>> >   * @__state:  drm_atomic_state pointer
>> >   * @plane:  drm_plane iteration cursor
>> > --
>> > 2.7.4
>> >
>> > ___
>> > amd-gfx mailing list
>> > amd-...@lists.freedesktop.org
>> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>> ___
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
> --
> Daniel Vetter
> Software Engineer, 

[PATCH] drm/atomic: Add new reverse iterator over all plane state (V2)

2018-03-06 Thread Shirish S
Add reverse iterator for_each_oldnew_plane_in_state_reverse to
compliment the for_each_oldnew_plane_in_state way or reading plane
states.

The plane states are required to be read in reverse order for
amd drivers, cause the z order convention followed in linux is
opposite to how the planes are supposed to be presented to DC
engine, which is in common to both windows and linux.

V2: fix compile time errors due to -Werror flag.

Signed-off-by: Shirish S 
Signed-off-by: Pratik Vishwakarma 
Reviewed-by: Daniel Vetter 
---
 include/drm/drm_atomic.h | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index cf13842..3fe8dde 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -754,6 +754,28 @@ void drm_state_dump(struct drm_device *dev, struct 
drm_printer *p);
  (new_plane_state) = 
(__state)->planes[__i].new_state, 1))
 
 /**
+ * for_each_oldnew_plane_in_state_reverse - iterate over all planes in an 
atomic
+ * update in reverse order
+ * @__state:  drm_atomic_state pointer
+ * @plane:  drm_plane iteration cursor
+ * @old_plane_state:  drm_plane_state iteration cursor for the old state
+ * @new_plane_state:  drm_plane_state iteration cursor for the new state
+ * @__i: int iteration cursor, for macro-internal use
+ *
+ * This iterates over all planes in an atomic update in reverse order,
+ * tracking both old and  new state. This is useful in places where the
+ * state delta needs to be considered, for example in atomic check functions.
+ */
+#define for_each_oldnew_plane_in_state_reverse(__state, plane, 
old_plane_state, new_plane_state, __i) \
+   for ((__i) = ((__state)->dev->mode_config.num_total_plane - 1); \
+(__i) >= 0;\
+(__i)--)   \
+   for_each_if ((__state)->planes[__i].ptr &&  \
+((plane) = (__state)->planes[__i].ptr, \
+ (old_plane_state) = 
(__state)->planes[__i].old_state,\
+ (new_plane_state) = 
(__state)->planes[__i].new_state, 1))
+
+/**
  * for_each_old_plane_in_state - iterate over all planes in an atomic update
  * @__state:  drm_atomic_state pointer
  * @plane:  drm_plane iteration cursor
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[radeon-alex:amd-staging-drm-next 3/5] drivers/gpu/drm/ttm/ttm_tt.c:240:6: sparse: symbol 'ttm_tt_init_fields' was not declared. Should it be static?

2018-03-06 Thread kbuild test robot
tree:   git://people.freedesktop.org/~agd5f/linux.git amd-staging-drm-next
head:   085145ebf0e9c401e18cd9f7b2dd835a20c188c9
commit: 69665e4b79150133c3b28807f212972a1d3a392a [3/5] drm/ttm: add 
ttm_sg_tt_init
reproduce:
# apt-get install sparse
git checkout 69665e4b79150133c3b28807f212972a1d3a392a
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/ttm/ttm_tt.c:240:6: sparse: symbol 'ttm_tt_init_fields' was 
>> not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC PATCH radeon-alex] drm/ttm: ttm_tt_init_fields() can be static

2018-03-06 Thread kbuild test robot

Fixes: 69665e4b7915 ("drm/ttm: add ttm_sg_tt_init")
Signed-off-by: Fengguang Wu 
---
 ttm_tt.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 9711331..45c8ae1 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -237,8 +237,8 @@ void ttm_tt_destroy(struct ttm_tt *ttm)
ttm->func->destroy(ttm);
 }
 
-void ttm_tt_init_fields(struct ttm_tt *ttm, struct ttm_bo_device *bdev,
-   unsigned long size, uint32_t page_flags)
+static void ttm_tt_init_fields(struct ttm_tt *ttm, struct ttm_bo_device *bdev,
+  unsigned long size, uint32_t page_flags)
 {
ttm->bdev = bdev;
ttm->num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 1/8] drm/blend: Add a generic alpha property

2018-03-06 Thread Stefan Schake
Hey,

On Wed, Feb 21, 2018 at 2:04 PM, Maxime Ripard
 wrote:
>
> What is the behaviour of the tegra engine when it has both a
> pixel-alpha and a plane-alpha?
>
> Atmel at least will drop one (but I'm not sure which one anymore).

Sorry, I have no more on the Tegra beyond that commit. But I did have some
more play time with drm_hwcomposer and from the rendering, it certainly
expects both to apply at the same time. To further complicate it, from
what I can tell with the VC4 HVS, you can actually configure it to
1) use only pixel alpha 2) use only plane alpha or 3) mix both pixel
and plane alpha, with 3 being what drm_hwc seems to want.

I think once writeback lands it would be a good idea to have some tests
that establish DRM plane blending standards beyond text in docs :)

Regards,
Stefan
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH] drm/dp: Correctly mask DP_TRAINING_AUX_RD_INTERVAL values for DP 1.4

2018-03-06 Thread Pandiyan, Dhinakaran



On Tue, 2018-03-06 at 17:36 -0800, Manasi Navare wrote:
> On Wed, Mar 07, 2018 at 12:24:46AM +, Pandiyan, Dhinakaran wrote:
> > 
> > 
> > 
> > On Tue, 2018-03-06 at 15:24 -0800, Rodrigo Vivi wrote:
> > > On Tue, Mar 06, 2018 at 10:37:48AM -0800, matthew.s.atw...@intel.com 
> > > wrote:
> > > > From: Matt Atwood 
> > > > 
> > > > DP_TRAINING_AUX_RD_INTERVAL with DP 1.3 spec changed bit scheme from 8
> > > > bits to 7 bits in DPCD 0x000e. The 8th bit describes a new feature, for
> > > > panels that use this new feature, this would cause a wait interval for
> > > > clock recovery of at least 512 ms, much higher then spec maximum of 16 
> > > > ms.
> > > > This behavior is described in table 2-158 of DP 1.4 spec address Eh.
> > > > To avoid breaking panels 
> > 
> > See comment below:
> > 
> > > that are not spec compliant we now warn on
> > > > invalid values.
> > > > 
> > > > V2: commit title/message, masking all 7 bits, warn on out of spec 
> > > > values.
> > > 
> > > this approach is even better imho.
> > > 
> > > > 
> > > > Signed-off-by: Matt Atwood 
> > > 
> > > Reviewed-by: Rodrigo Vivi 
> > > 
> > > > ---
> > > >  drivers/gpu/drm/drm_dp_helper.c | 18 ++
> > > >  include/drm/drm_dp_helper.h |  1 +
> > > >  2 files changed, 15 insertions(+), 4 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/drm_dp_helper.c 
> > > > b/drivers/gpu/drm/drm_dp_helper.c
> > > > index adf79be..a718ccc 100644
> > > > --- a/drivers/gpu/drm/drm_dp_helper.c
> > > > +++ b/drivers/gpu/drm/drm_dp_helper.c
> > > > @@ -119,18 +119,28 @@ u8 drm_dp_get_adjust_request_pre_emphasis(const 
> > > > u8 link_status[DP_LINK_STATUS_SI
> > > >  EXPORT_SYMBOL(drm_dp_get_adjust_request_pre_emphasis);
> > > >  
> > > >  void drm_dp_link_train_clock_recovery_delay(const u8 
> > > > dpcd[DP_RECEIVER_CAP_SIZE]) {
> > > > -   if (dpcd[DP_TRAINING_AUX_RD_INTERVAL] == 0)
> > > > +   int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & 
> > > > DP_TRAINING_AUX_RD_MASK;
> > > > +
> > > > +   if (rd_interval > 4)
> > > > +   DRM_DEBUG_KMS("AUX interval %d, out of range (max 4)", 
> > > > rd_interval);
> > 
> > Some default for panels without a valid value?
> > rd_interval = 4;
> > "AUX read interval out of range, using max %d ms"
> >
> 
> The problem with setting the upper bound to 4 is that there are panels
> that do not follow the spec and expect a longer than 16 ms delay. So
> if we set the upper bound to 4 in those cases the panels might not work.
> 
> So we decided to go with this approach where we tell the users that panel is 
> requesting
> out of range AUX value but then set it to the value * 4 in the else part.
> 

Thanks for the clarification. My concern is if the DPCD is advertizing
an out of spec value, it might as well be advertizing a delay that the
panel doesn't need. And I thought panel quirks were supposed to be used
for working around things like this. To be clear, this is not a big
enough concern to block this fix.

Like I said in the other email, this patch refers to DP 1.4, shouldn't
the clock recovery delay be updated too (in a separate patch)?


> Manasi
>  
> >   
> > > > +
> > > > +   if (rd_interval == 0)
> > > > udelay(100);
> > > > else
> > > > -   mdelay(dpcd[DP_TRAINING_AUX_RD_INTERVAL] * 4);
> > > > +   mdelay(rd_interval * 4);
> > > >  }
> > > >  EXPORT_SYMBOL(drm_dp_link_train_clock_recovery_delay);
> > > >  
> > > >  void drm_dp_link_train_channel_eq_delay(const u8 
> > > > dpcd[DP_RECEIVER_CAP_SIZE]) {
> > > > -   if (dpcd[DP_TRAINING_AUX_RD_INTERVAL] == 0)
> > > > +   int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & 
> > > > DP_TRAINING_AUX_RD_MASK;
> > > > +
> > > > +   if (rd_interval > 4)
> > > > +   DRM_DEBUG_KMS("AUX interval %d, out of range (max 4)", 
> > > > rd_interval);
> > > > +
> > > > +   if (rd_interval == 0)
> > > > udelay(400);
> > > > else
> > > > -   mdelay(dpcd[DP_TRAINING_AUX_RD_INTERVAL] * 4);
> > > > +   mdelay(rd_interval * 4);
> > > >  }
> > > >  EXPORT_SYMBOL(drm_dp_link_train_channel_eq_delay);
> > > >  
> > > > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> > > > index da58a42..f80acf1 100644
> > > > --- a/include/drm/drm_dp_helper.h
> > > > +++ b/include/drm/drm_dp_helper.h
> > > > @@ -118,6 +118,7 @@
> > > >  # define DP_DPCD_DISPLAY_CONTROL_CAPABLE (1 << 3) /* edp v1.2 or 
> > > > higher */
> > > >  
> > > >  #define DP_TRAINING_AUX_RD_INTERVAL 0x00e   /* XXX 1.2? */
> > > > +# define DP_TRAINING_AUX_RD_MASK0x7F /* 1.3 */
> > > >  
> > > >  #define DP_ADAPTER_CAP 0x00f   /* 1.2 */
> > > >  # define DP_FORCE_LOAD_SENSE_CAP   (1 << 0)
> > > > -- 
> > > > 2.7.4
> > > > 
> > > > 

Re: [Intel-gfx] [PATCH] drm/dp: Correctly mask DP_TRAINING_AUX_RD_INTERVAL values for DP 1.4

2018-03-06 Thread Manasi Navare
On Wed, Mar 07, 2018 at 12:24:46AM +, Pandiyan, Dhinakaran wrote:
> 
> 
> 
> On Tue, 2018-03-06 at 15:24 -0800, Rodrigo Vivi wrote:
> > On Tue, Mar 06, 2018 at 10:37:48AM -0800, matthew.s.atw...@intel.com wrote:
> > > From: Matt Atwood 
> > > 
> > > DP_TRAINING_AUX_RD_INTERVAL with DP 1.3 spec changed bit scheme from 8
> > > bits to 7 bits in DPCD 0x000e. The 8th bit describes a new feature, for
> > > panels that use this new feature, this would cause a wait interval for
> > > clock recovery of at least 512 ms, much higher then spec maximum of 16 ms.
> > > This behavior is described in table 2-158 of DP 1.4 spec address Eh.
> > > To avoid breaking panels 
> 
> See comment below:
> 
> > that are not spec compliant we now warn on
> > > invalid values.
> > > 
> > > V2: commit title/message, masking all 7 bits, warn on out of spec values.
> > 
> > this approach is even better imho.
> > 
> > > 
> > > Signed-off-by: Matt Atwood 
> > 
> > Reviewed-by: Rodrigo Vivi 
> > 
> > > ---
> > >  drivers/gpu/drm/drm_dp_helper.c | 18 ++
> > >  include/drm/drm_dp_helper.h |  1 +
> > >  2 files changed, 15 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_dp_helper.c 
> > > b/drivers/gpu/drm/drm_dp_helper.c
> > > index adf79be..a718ccc 100644
> > > --- a/drivers/gpu/drm/drm_dp_helper.c
> > > +++ b/drivers/gpu/drm/drm_dp_helper.c
> > > @@ -119,18 +119,28 @@ u8 drm_dp_get_adjust_request_pre_emphasis(const u8 
> > > link_status[DP_LINK_STATUS_SI
> > >  EXPORT_SYMBOL(drm_dp_get_adjust_request_pre_emphasis);
> > >  
> > >  void drm_dp_link_train_clock_recovery_delay(const u8 
> > > dpcd[DP_RECEIVER_CAP_SIZE]) {
> > > - if (dpcd[DP_TRAINING_AUX_RD_INTERVAL] == 0)
> > > + int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & 
> > > DP_TRAINING_AUX_RD_MASK;
> > > +
> > > + if (rd_interval > 4)
> > > + DRM_DEBUG_KMS("AUX interval %d, out of range (max 4)", 
> > > rd_interval);
> 
> Some default for panels without a valid value?
>   rd_interval = 4;
>   "AUX read interval out of range, using max %d ms"
>

The problem with setting the upper bound to 4 is that there are panels
that do not follow the spec and expect a longer than 16 ms delay. So
if we set the upper bound to 4 in those cases the panels might not work.

So we decided to go with this approach where we tell the users that panel is 
requesting
out of range AUX value but then set it to the value * 4 in the else part.

Manasi
 
> 
> > > +
> > > + if (rd_interval == 0)
> > >   udelay(100);
> > >   else
> > > - mdelay(dpcd[DP_TRAINING_AUX_RD_INTERVAL] * 4);
> > > + mdelay(rd_interval * 4);
> > >  }
> > >  EXPORT_SYMBOL(drm_dp_link_train_clock_recovery_delay);
> > >  
> > >  void drm_dp_link_train_channel_eq_delay(const u8 
> > > dpcd[DP_RECEIVER_CAP_SIZE]) {
> > > - if (dpcd[DP_TRAINING_AUX_RD_INTERVAL] == 0)
> > > + int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & 
> > > DP_TRAINING_AUX_RD_MASK;
> > > +
> > > + if (rd_interval > 4)
> > > + DRM_DEBUG_KMS("AUX interval %d, out of range (max 4)", 
> > > rd_interval);
> > > +
> > > + if (rd_interval == 0)
> > >   udelay(400);
> > >   else
> > > - mdelay(dpcd[DP_TRAINING_AUX_RD_INTERVAL] * 4);
> > > + mdelay(rd_interval * 4);
> > >  }
> > >  EXPORT_SYMBOL(drm_dp_link_train_channel_eq_delay);
> > >  
> > > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> > > index da58a42..f80acf1 100644
> > > --- a/include/drm/drm_dp_helper.h
> > > +++ b/include/drm/drm_dp_helper.h
> > > @@ -118,6 +118,7 @@
> > >  # define DP_DPCD_DISPLAY_CONTROL_CAPABLE (1 << 3) /* edp v1.2 or 
> > > higher */
> > >  
> > >  #define DP_TRAINING_AUX_RD_INTERVAL 0x00e   /* XXX 1.2? */
> > > +# define DP_TRAINING_AUX_RD_MASK0x7F /* 1.3 */
> > >  
> > >  #define DP_ADAPTER_CAP   0x00f   /* 1.2 */
> > >  # define DP_FORCE_LOAD_SENSE_CAP (1 << 0)
> > > -- 
> > > 2.7.4
> > > 
> > > ___
> > > Intel-gfx mailing list
> > > intel-...@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> > ___
> > Intel-gfx mailing list
> > intel-...@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> ___
> Intel-gfx mailing list
> intel-...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v6 5/9] drm: Handle aspect-ratio info in getblob

2018-03-06 Thread kbuild test robot
Hi Ankit,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm/drm-next]
[also build test WARNING on v4.16-rc4 next-20180306]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Nautiyal-Ankit-K/Aspect-ratio-support-in-DRM-layer/20180307-064609
base:   git://people.freedesktop.org/~airlied/linux.git drm-next
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   include/linux/crypto.h:477: warning: Function parameter or member 
'cra_u.blkcipher' not described in 'crypto_alg'
   include/linux/crypto.h:477: warning: Function parameter or member 
'cra_u.cipher' not described in 'crypto_alg'
   include/linux/crypto.h:477: warning: Function parameter or member 
'cra_u.compress' not described in 'crypto_alg'
   include/net/cfg80211.h:4129: warning: Function parameter or member 
'wext.ibss' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 
'wext.connect' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 
'wext.keys' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.ie' 
not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 
'wext.ie_len' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 
'wext.bssid' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 
'wext.prev_bssid' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 
'wext.ssid' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 
'wext.default_key' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 
'wext.default_mgmt_key' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 
'wext.prev_bssid_valid' not described in 'wireless_dev'
   include/net/mac80211.h:2259: warning: Function parameter or member 
'radiotap_timestamp.units_pos' not described in 'ieee80211_hw'
   include/net/mac80211.h:2259: warning: Function parameter or member 
'radiotap_timestamp.accuracy' not described in 'ieee80211_hw'
   include/net/mac80211.h:950: warning: Function parameter or member 'rates' 
not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'control.rts_cts_rate_idx' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'control.use_rts' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'control.use_cts_prot' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'control.short_preamble' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'control.skip_table' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'control.jiffies' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'control.vif' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'control.hw_key' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'control.flags' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'control.enqueue_time' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'ack' not 
described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'ack.cookie' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'status.rates' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'status.ack_signal' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'status.ampdu_ack_len' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'status.ampdu_len' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'status.antenna' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'status.tx_time' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 
'status_driver_data' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function par

Re: [Intel-gfx] [PATCH] drm/dp: Correctly mask DP_TRAINING_AUX_RD_INTERVAL values for DP 1.4

2018-03-06 Thread Pandiyan, Dhinakaran



On Tue, 2018-03-06 at 16:48 -0800, Dhinakaran Pandiyan wrote:
> 
> 
> On Tue, 2018-03-06 at 15:24 -0800, Rodrigo Vivi wrote:
> > On Tue, Mar 06, 2018 at 10:37:48AM -0800, matthew.s.atw...@intel.com wrote:
> > > From: Matt Atwood 
> > > 
> > > DP_TRAINING_AUX_RD_INTERVAL with DP 1.3 spec changed bit scheme from 8
> > > bits to 7 bits in DPCD 0x000e. The 8th bit describes a new feature, for
> > > panels that use this new feature, this would cause a wait interval for
> > > clock recovery of at least 512 ms, much higher then spec maximum of 16 ms.
> > > This behavior is described in table 2-158 of DP 1.4 spec address Eh.
> > > To avoid breaking panels 
> 
> See comment below:
> 
> > that are not spec compliant we now warn on
> > > invalid values.
> > > 
> > > V2: commit title/message, masking all 7 bits, warn on out of spec values.
> > 
> > this approach is even better imho.
> > 
> > > 
> > > Signed-off-by: Matt Atwood 
> > 
> > Reviewed-by: Rodrigo Vivi 
> > 
> > > ---
> > >  drivers/gpu/drm/drm_dp_helper.c | 18 ++
> > >  include/drm/drm_dp_helper.h |  1 +
> > >  2 files changed, 15 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_dp_helper.c 
> > > b/drivers/gpu/drm/drm_dp_helper.c
> > > index adf79be..a718ccc 100644
> > > --- a/drivers/gpu/drm/drm_dp_helper.c
> > > +++ b/drivers/gpu/drm/drm_dp_helper.c
> > > @@ -119,18 +119,28 @@ u8 drm_dp_get_adjust_request_pre_emphasis(const u8 
> > > link_status[DP_LINK_STATUS_SI
> > >  EXPORT_SYMBOL(drm_dp_get_adjust_request_pre_emphasis);
> > >  
> > >  void drm_dp_link_train_clock_recovery_delay(const u8 
> > > dpcd[DP_RECEIVER_CAP_SIZE]) {
> > > - if (dpcd[DP_TRAINING_AUX_RD_INTERVAL] == 0)
> > > + int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & 
> > > DP_TRAINING_AUX_RD_MASK;
> > > +
> > > + if (rd_interval > 4)
> > > + DRM_DEBUG_KMS("AUX interval %d, out of range (max 4)", 
> > > rd_interval);
> 
> Some default for panels without a valid value?
>   rd_interval = 4;
>   "AUX read interval out of range, using max %d ms"
> 
> 
> > > +
> > > + if (rd_interval == 0)
> > >   udelay(100);
> > >   else
> > > - mdelay(dpcd[DP_TRAINING_AUX_RD_INTERVAL] * 4);
> > > + mdelay(rd_interval * 4);

Btw, DP 1.4 spec also says this is 100 us for *all* values in the
register. Updating that for DP 1.4 panels should speed up link
training. 


> > >  }
> > >  EXPORT_SYMBOL(drm_dp_link_train_clock_recovery_delay);
> > >  
> > >  void drm_dp_link_train_channel_eq_delay(const u8 
> > > dpcd[DP_RECEIVER_CAP_SIZE]) {
> > > - if (dpcd[DP_TRAINING_AUX_RD_INTERVAL] == 0)
> > > + int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & 
> > > DP_TRAINING_AUX_RD_MASK;
> > > +
> > > + if (rd_interval > 4)
> > > + DRM_DEBUG_KMS("AUX interval %d, out of range (max 4)", 
> > > rd_interval);
> > > +
> > > + if (rd_interval == 0)
> > >   udelay(400);
> > >   else
> > > - mdelay(dpcd[DP_TRAINING_AUX_RD_INTERVAL] * 4);
> > > + mdelay(rd_interval * 4);
> > >  }
> > >  EXPORT_SYMBOL(drm_dp_link_train_channel_eq_delay);
> > >  
> > > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> > > index da58a42..f80acf1 100644
> > > --- a/include/drm/drm_dp_helper.h
> > > +++ b/include/drm/drm_dp_helper.h
> > > @@ -118,6 +118,7 @@
> > >  # define DP_DPCD_DISPLAY_CONTROL_CAPABLE (1 << 3) /* edp v1.2 or 
> > > higher */
> > >  
> > >  #define DP_TRAINING_AUX_RD_INTERVAL 0x00e   /* XXX 1.2? */
> > > +# define DP_TRAINING_AUX_RD_MASK0x7F /* 1.3 */
> > >  
> > >  #define DP_ADAPTER_CAP   0x00f   /* 1.2 */
> > >  # define DP_FORCE_LOAD_SENSE_CAP (1 << 0)
> > > -- 
> > > 2.7.4
> > > 
> > > ___
> > > Intel-gfx mailing list
> > > intel-...@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> > ___
> > Intel-gfx mailing list
> > intel-...@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 43/60] drm/omap: dss: Acquire next dssdev at probe time

2018-03-06 Thread Laurent Pinchart
Look up the next dssdev at probe time based on device tree links for all
DSS outputs and encoders. This will be used to reverse the order of the
dssdev connect and disconnect call chains.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c|  9 +
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c|  9 +
 drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c |  9 +
 drivers/gpu/drm/omapdrm/dss/dpi.c| 17 +
 drivers/gpu/drm/omapdrm/dss/dsi.c| 18 --
 drivers/gpu/drm/omapdrm/dss/hdmi4.c  | 18 --
 drivers/gpu/drm/omapdrm/dss/hdmi5.c  | 18 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h|  1 +
 drivers/gpu/drm/omapdrm/dss/sdi.c| 17 +++--
 drivers/gpu/drm/omapdrm/dss/venc.c   | 18 --
 10 files changed, 120 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index 904ebec5f5e1..a94d6d0cead9 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -169,6 +169,13 @@ static int opa362_probe(struct platform_device *pdev)
dssdev->owner = THIS_MODULE;
dssdev->of_ports = BIT(1) | BIT(0);
 
+   dssdev->next = omapdss_of_find_connected_device(pdev->dev.of_node, 1);
+   if (IS_ERR(dssdev->next)) {
+   if (PTR_ERR(dssdev->next) != -EPROBE_DEFER)
+   dev_err(>dev, "failed to find video sink\n");
+   return PTR_ERR(dssdev->next);
+   }
+
omapdss_device_register(dssdev);
 
return 0;
@@ -179,6 +186,8 @@ static int __exit opa362_remove(struct platform_device 
*pdev)
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *dssdev = >dssdev;
 
+   if (dssdev->next)
+   omapdss_device_put(dssdev->next);
omapdss_device_unregister(>dssdev);
 
WARN_ON(omapdss_device_is_enabled(dssdev));
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index cd442f66fa1d..d40a0fd93e67 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -192,6 +192,13 @@ static int tfp410_probe(struct platform_device *pdev)
dssdev->owner = THIS_MODULE;
dssdev->of_ports = BIT(1) | BIT(0);
 
+   dssdev->next = omapdss_of_find_connected_device(pdev->dev.of_node, 1);
+   if (IS_ERR(dssdev->next)) {
+   if (PTR_ERR(dssdev->next) != -EPROBE_DEFER)
+   dev_err(>dev, "failed to find video sink\n");
+   return PTR_ERR(dssdev->next);
+   }
+
omapdss_device_register(dssdev);
 
return 0;
@@ -202,6 +209,8 @@ static int __exit tfp410_remove(struct platform_device 
*pdev)
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *dssdev = >dssdev;
 
+   if (dssdev->next)
+   omapdss_device_put(dssdev->next);
omapdss_device_unregister(>dssdev);
 
WARN_ON(omapdss_device_is_enabled(dssdev));
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
index c32eb7537d5a..0f7943cfc4b5 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
@@ -292,6 +292,13 @@ static int tpd_probe(struct platform_device *pdev)
dssdev->owner = THIS_MODULE;
dssdev->of_ports = BIT(1) | BIT(0);
 
+   dssdev->next = omapdss_of_find_connected_device(pdev->dev.of_node, 1);
+   if (IS_ERR(dssdev->next)) {
+   if (PTR_ERR(dssdev->next) != -EPROBE_DEFER)
+   dev_err(>dev, "failed to find video sink\n");
+   return PTR_ERR(dssdev->next);
+   }
+
omapdss_device_register(dssdev);
 
return 0;
@@ -302,6 +309,8 @@ static int __exit tpd_remove(struct platform_device *pdev)
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *dssdev = >dssdev;
 
+   if (dssdev->next)
+   omapdss_device_put(dssdev->next);
omapdss_device_unregister(>dssdev);
 
WARN_ON(omapdss_device_is_enabled(dssdev));
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index dc189b717fef..b73d7aad3d89 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -687,7 +687,7 @@ static const struct omap_dss_device_ops dpi_ops = {
.set_timings = dpi_set_timings,
 };
 
-static void dpi_init_output_port(struct dpi_data *dpi, struct device_node 
*port)
+static int dpi_init_output_port(struct 

[PATCH/RFC 51/60] drm/omap: Reverse direction of DSS device (dis)connect operations

2018-03-06 Thread Laurent Pinchart
The omapdrm and omapdss drivers are architectured based on display
pipelines made of multiple components handled from sink (display) to
source (DSS output). This is incompatible with the DRM bridge and panel
APIs that handle components from source to sink.

To reconcile the omapdrm and omapdss drivers with the DRM bridge and
panel model, we need to reverse the direction of the DSS device
operations. Start with the connect and disconnect operations.

Signed-off-by: Laurent Pinchart 
---
 .../gpu/drm/omapdrm/displays/connector-analog-tv.c | 27 +++---
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c   | 27 +++---
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c  | 27 +++---
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c  | 34 --
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c  | 34 --
 .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c   | 32 ++---
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c   | 27 +++---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c| 42 ++
 .../omapdrm/displays/panel-lgphilips-lb035q02.c| 28 +++
 .../drm/omapdrm/displays/panel-nec-nl8048hl11.c| 27 +++---
 .../drm/omapdrm/displays/panel-sharp-ls037v7dw01.c | 27 +++---
 .../drm/omapdrm/displays/panel-sony-acx565akm.c| 27 +++---
 .../drm/omapdrm/displays/panel-tpo-td028ttec1.c| 27 +++---
 .../drm/omapdrm/displays/panel-tpo-td043mtea1.c| 27 +++---
 drivers/gpu/drm/omapdrm/dss/base.c | 30 
 drivers/gpu/drm/omapdrm/dss/dpi.c  | 32 +++--
 drivers/gpu/drm/omapdrm/dss/dsi.c  | 32 +++--
 drivers/gpu/drm/omapdrm/dss/hdmi4.c| 30 ++--
 drivers/gpu/drm/omapdrm/dss/hdmi5.c| 30 ++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  6 ++--
 drivers/gpu/drm/omapdrm/dss/sdi.c  | 30 ++--
 drivers/gpu/drm/omapdrm/dss/venc.c | 30 ++--
 drivers/gpu/drm/omapdrm/omap_drv.c | 35 ++
 drivers/gpu/drm/omapdrm/omap_drv.h |  1 +
 24 files changed, 238 insertions(+), 431 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index eab898b5bf0f..d59b4f2e22dc 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -41,33 +41,15 @@ static const struct videomode tvc_pal_vm = {
 
 #define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
 
-static int tvc_connect(struct omap_dss_device *dssdev)
+static int tvc_connect(struct omap_dss_device *src,
+  struct omap_dss_device *dst)
 {
-   struct omap_dss_device *src;
-   int r;
-
-   src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
-   if (IS_ERR_OR_NULL(src)) {
-   dev_err(dssdev->dev, "failed to find video source\n");
-   return src ? PTR_ERR(src) : -EINVAL;
-   }
-
-   r = omapdss_device_connect(dssdev->dss, src, dssdev);
-   if (r) {
-   omapdss_device_put(src);
-   return r;
-   }
-
return 0;
 }
 
-static void tvc_disconnect(struct omap_dss_device *dssdev)
+static void tvc_disconnect(struct omap_dss_device *src,
+  struct omap_dss_device *dst)
 {
-   struct omap_dss_device *src = dssdev->src;
-
-   omapdss_device_disconnect(src, dssdev);
-
-   omapdss_device_put(src);
 }
 
 static int tvc_enable(struct omap_dss_device *dssdev)
@@ -184,7 +166,6 @@ static int __exit tvc_remove(struct platform_device *pdev)
omapdss_device_unregister(>dssdev);
 
tvc_disable(dssdev);
-   tvc_disconnect(dssdev);
 
return 0;
 }
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 6eae18b42b82..39e7d0be887f 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -56,33 +56,15 @@ struct panel_drv_data {
 
 #define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
 
-static int dvic_connect(struct omap_dss_device *dssdev)
+static int dvic_connect(struct omap_dss_device *src,
+   struct omap_dss_device *dst)
 {
-   struct omap_dss_device *src;
-   int r;
-
-   src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
-   if (IS_ERR_OR_NULL(src)) {
-   dev_err(dssdev->dev, "failed to find video source\n");
-   return src ? PTR_ERR(src) : -EINVAL;
-   }
-
-   r = omapdss_device_connect(dssdev->dss, src, dssdev);
-   if (r) {
-   omapdss_device_put(src);
-   return r;
-   }
-

[PATCH/RFC 53/60] drm/omap: dss: Move display type validation to initialization time

2018-03-06 Thread Laurent Pinchart
The display type is validated when the display is connected to the DSS
output. We already have all the information we need for validation when
initializing the outputs. Move validation to output initialization to
simplify pipeline connection handling.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c | 25 +++--
 drivers/gpu/drm/omapdrm/dss/dsi.c | 25 +++--
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   | 25 +++--
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   | 25 +++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 +--
 drivers/gpu/drm/omapdrm/dss/output.c  | 17 +
 drivers/gpu/drm/omapdrm/dss/sdi.c | 25 +++--
 drivers/gpu/drm/omapdrm/dss/venc.c| 25 +++--
 8 files changed, 72 insertions(+), 98 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 97f6bba1a510..3c4863e351f0 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -619,24 +619,13 @@ static int dpi_connect(struct omap_dss_device *src,
if (r)
return r;
 
-   r = omapdss_output_set_device(dst, dst->next);
+   r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r) {
-   DSSERR("failed to connect output to new device: %s\n",
-   dst->name);
-   goto err_mgr_disconnect;
+   dss_mgr_disconnect(dst);
+   return r;
}
 
-   r = omapdss_device_connect(dst->dss, dst, dst->next);
-   if (r)
-   goto err_output_unset;
-
return 0;
-
-err_output_unset:
-   omapdss_output_unset_device(dst);
-err_mgr_disconnect:
-   dss_mgr_disconnect(dst);
-   return r;
 }
 
 static void dpi_disconnect(struct omap_dss_device *src,
@@ -663,6 +652,7 @@ static int dpi_init_output_port(struct dpi_data *dpi, 
struct device_node *port)
 {
struct omap_dss_device *out = >output;
u32 port_num = 0;
+   int r;
 
of_property_read_u32(port, "reg", _num);
dpi->id = port_num <= 2 ? port_num : 0;
@@ -695,6 +685,13 @@ static int dpi_init_output_port(struct dpi_data *dpi, 
struct device_node *port)
return PTR_ERR(out->next);
}
 
+   r = omapdss_output_validate(out);
+   if (r) {
+   omapdss_device_put(out->next);
+   out->next = NULL;
+   return r;
+   }
+
omapdss_device_register(out);
 
return 0;
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index a5516d6e8017..53a32e20c3bd 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4890,24 +4890,13 @@ static int dsi_connect(struct omap_dss_device *src,
if (r)
return r;
 
-   r = omapdss_output_set_device(dst, dst->next);
+   r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r) {
-   DSSERR("failed to connect output to new device: %s\n",
-   dst->name);
-   goto err_mgr_disconnect;
+   dss_mgr_disconnect(dst);
+   return r;
}
 
-   r = omapdss_device_connect(dst->dss, dst, dst->next);
-   if (r)
-   goto err_output_unset;
-
return 0;
-
-err_output_unset:
-   omapdss_output_unset_device(dst);
-err_mgr_disconnect:
-   dss_mgr_disconnect(dst);
-   return r;
 }
 
 static void dsi_disconnect(struct omap_dss_device *src,
@@ -5147,6 +5136,7 @@ static const struct component_ops dsi_component_ops = {
 static int dsi_init_output(struct dsi_data *dsi)
 {
struct omap_dss_device *out = >output;
+   int r;
 
out->dev = dsi->dev;
out->id = dsi->module_id == 0 ?
@@ -5166,6 +5156,13 @@ static int dsi_init_output(struct dsi_data *dsi)
return PTR_ERR(out->next);
}
 
+   r = omapdss_output_validate(out);
+   if (r) {
+   omapdss_device_put(out->next);
+   out->next = NULL;
+   return r;
+   }
+
omapdss_device_register(out);
 
return 0;
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index d73a924c745c..1d852928ed6f 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -437,24 +437,13 @@ static int hdmi_connect(struct omap_dss_device *src,
if (r)
return r;
 
-   r = omapdss_output_set_device(dst, dst->next);
+   r = omapdss_device_connect(dst->dss, dst, dst->next);
if (r) {
-   DSSERR("failed to connect output to new device: %s\n",
-   dst->name);
-   goto err_mgr_disconnect;
+   dss_mgr_disconnect(dst);
+   return r;
}
 
-   r = 

[PATCH/RFC 36/60] drm/omap: dss: Extend omapdss_of_find_source_for_first_ep() to sinks

2018-03-06 Thread Laurent Pinchart
The omapdss_of_find_source_for_first_ep() function locates the source
corresponding to the first endpoint of the first port of a device node.
We can easily extend it to locate sinks as well by passing the port
number as a parameter. This will be useful to find sinks in encoders
drivers.

Extend the function and rename it to omapdss_of_find_connected_device()
to reflect its new extended purpose.

Additionally, it is useful to differentiate between failures to return
the connected device because no link exists in the device tree for the
requested port, or because the connected device as described in the
device tree is invalid or not probed yet. Return NULL in the first case
and an error code in the second case, and update the callers
accordingly.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c |  6 +++---
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c   |  6 +++---
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c  |  6 +++---
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c  |  2 +-
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c  |  2 +-
 drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c   |  2 +-
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c   |  6 +++---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c|  6 +++---
 .../gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c|  6 +++---
 drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c|  6 +++---
 drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c |  6 +++---
 drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c|  6 +++---
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c|  6 +++---
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c|  6 +++---
 drivers/gpu/drm/omapdrm/dss/dss-of.c   | 14 +++---
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  2 +-
 16 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index b960c4d0e84d..4f32c8ddcfbd 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -47,10 +47,10 @@ static int tvc_connect(struct omap_dss_device *dssdev)
struct omap_dss_device *src;
int r;
 
-   src = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
-   if (IS_ERR(src)) {
+   src = omapdss_of_find_connected_device(ddata->dev->of_node, 0);
+   if (IS_ERR_OR_NULL(src)) {
dev_err(ddata->dev, "failed to find video source\n");
-   return PTR_ERR(src);
+   return src ? PTR_ERR(src) : -EINVAL;
}
 
r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 8ff674bf75e6..6eae18b42b82 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -61,10 +61,10 @@ static int dvic_connect(struct omap_dss_device *dssdev)
struct omap_dss_device *src;
int r;
 
-   src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
-   if (IS_ERR(src)) {
+   src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
+   if (IS_ERR_OR_NULL(src)) {
dev_err(dssdev->dev, "failed to find video source\n");
-   return PTR_ERR(src);
+   return src ? PTR_ERR(src) : -EINVAL;
}
 
r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 439a7bb0a5f4..1df7ffd8b97d 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -57,10 +57,10 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
struct omap_dss_device *src;
int r;
 
-   src = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
-   if (IS_ERR(src)) {
+   src = omapdss_of_find_connected_device(ddata->dev->of_node, 0);
+   if (IS_ERR_OR_NULL(src)) {
dev_err(ddata->dev, "failed to find video source\n");
-   return PTR_ERR(src);
+   return src ? PTR_ERR(src) : -EINVAL;
}
 
r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index eb0ebb850114..904ebec5f5e1 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -37,7 +37,7 @@ static int opa362_connect(struct omap_dss_device *dssdev,
struct omap_dss_device *src;
int r;
 
-   src = 

[PATCH/RFC 58/60] drm/omap: Remove supported output check in CRTC connect handler

2018-03-06 Thread Laurent Pinchart
The CRTC connect handler checks whether the DSS output supports the
DISPC channel assigned to it. As the channel is assigned to the output
by the output driver a failure there could only result from a driver
bug. All the output drivers have been verified and they are always
assigned a DISPC channel that is supported on the SoC they run on. The
check can thus be removed.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 8 
 drivers/gpu/drm/omapdrm/dss/dss.c | 6 --
 drivers/gpu/drm/omapdrm/dss/dss.h | 2 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 2 --
 drivers/gpu/drm/omapdrm/omap_crtc.c   | 6 --
 5 files changed, 24 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 5e2e65e88847..1e69c0483f42 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -2898,13 +2898,6 @@ static int dispc_ovl_enable(struct dispc_device *dispc,
return 0;
 }
 
-static enum omap_dss_output_id
-dispc_mgr_get_supported_outputs(struct dispc_device *dispc,
-   enum omap_channel channel)
-{
-   return dss_get_supported_outputs(dispc->dss, channel);
-}
-
 static void dispc_lcd_enable_signal_polarity(struct dispc_device *dispc,
 bool act_high)
 {
@@ -4736,7 +4729,6 @@ static const struct dispc_ops dispc_ops = {
.mgr_set_lcd_config = dispc_mgr_set_lcd_config,
.mgr_set_timings = dispc_mgr_set_timings,
.mgr_setup = dispc_mgr_setup,
-   .mgr_get_supported_outputs = dispc_mgr_get_supported_outputs,
.mgr_gamma_size = dispc_mgr_gamma_size,
.mgr_set_gamma = dispc_mgr_set_gamma,
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 79bc43135808..e68154ca2b43 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -671,12 +671,6 @@ unsigned long dss_get_max_fck_rate(struct dss_device *dss)
return dss->feat->fck_freq_max;
 }
 
-enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss,
- enum omap_channel channel)
-{
-   return dss->feat->outputs[channel];
-}
-
 static int dss_setup_default_clock(struct dss_device *dss)
 {
unsigned long max_dss_fck, prate;
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index 6dc2965649e8..5018e04d5651 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -314,8 +314,6 @@ void dss_runtime_put(struct dss_device *dss);
 
 unsigned long dss_get_dispc_clk_rate(struct dss_device *dss);
 unsigned long dss_get_max_fck_rate(struct dss_device *dss);
-enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss,
- enum omap_channel channel);
 int dss_dpi_select_source(struct dss_device *dss, int port,
  enum omap_channel channel);
 void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 9ba7c7e6e4f0..004195829b4f 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -634,8 +634,6 @@ struct dispc_ops {
const struct videomode *vm);
void (*mgr_setup)(struct dispc_device *dispc, enum omap_channel channel,
  const struct omap_overlay_manager_info *info);
-   enum omap_dss_output_id (*mgr_get_supported_outputs)(
-   struct dispc_device *dispc, enum omap_channel channel);
u32 (*mgr_gamma_size)(struct dispc_device *dispc,
  enum omap_channel channel);
void (*mgr_set_gamma)(struct dispc_device *dispc,
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 5a56c8e02179..90917d040ddb 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -114,12 +114,6 @@ static int omap_crtc_dss_connect(struct omap_drm_private 
*priv,
enum omap_channel channel,
struct omap_dss_device *dst)
 {
-   const struct dispc_ops *dispc_ops = priv->dispc_ops;
-   struct dispc_device *dispc = priv->dispc;
-
-   if (!(dispc_ops->mgr_get_supported_outputs(dispc, channel) & dst->id))
-   return -EINVAL;
-
dst->dispc_channel_connected = true;
 
return 0;
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 55/60] drm/omap: Pass pipe pointer to omap_crtc_init()

2018-03-06 Thread Laurent Pinchart
Replace the dss display device pointer by a pipe pointer that will allow
the omap_crtc_init() function to access both the display and the DSS
output. As a result we can remove the omapdss_device_get_dispc_channel()
function that is now unneeded.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/base.c| 9 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 1 -
 drivers/gpu/drm/omapdrm/omap_crtc.c   | 7 ---
 drivers/gpu/drm/omapdrm/omap_crtc.h   | 4 +++-
 drivers/gpu/drm/omapdrm/omap_drv.c| 2 +-
 5 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index fbb600d49ad2..cce09a48d769 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -247,15 +247,6 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
 }
 EXPORT_SYMBOL_GPL(omapdss_device_disconnect);
 
-enum omap_channel omapdss_device_get_dispc_channel(struct omap_dss_device 
*dssdev)
-{
-   while (dssdev->src)
-   dssdev = dssdev->src;
-
-   return dssdev->dispc_channel;
-}
-EXPORT_SYMBOL(omapdss_device_get_dispc_channel);
-
 /* 
-
  * Components Handling
  */
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index fd0d0082605d..9ba7c7e6e4f0 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -507,7 +507,6 @@ int omapdss_device_connect(struct dss_device *dss,
   struct omap_dss_device *dst);
 void omapdss_device_disconnect(struct omap_dss_device *src,
   struct omap_dss_device *dst);
-enum omap_channel omapdss_device_get_dispc_channel(struct omap_dss_device 
*dssdev);
 
 int omap_dss_get_num_overlay_managers(void);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index f5bf553a862f..f5bdb8de98f4 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -693,7 +693,8 @@ void omap_crtc_pre_uninit(struct omap_drm_private *priv)
 
 /* initialize crtc */
 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
-   struct drm_plane *plane, struct omap_dss_device *dssdev)
+   struct omap_drm_pipeline *pipe,
+   struct drm_plane *plane)
 {
struct omap_drm_private *priv = dev->dev_private;
struct drm_crtc *crtc = NULL;
@@ -701,7 +702,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
enum omap_channel channel;
int ret;
 
-   channel = omapdss_device_get_dispc_channel(dssdev);
+   channel = pipe->output->dispc_channel;
 
DBG("%s", channel_names[channel]);
 
@@ -724,7 +725,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
_crtc_funcs, NULL);
if (ret < 0) {
dev_err(dev->dev, "%s(): could not init crtc for: %s\n",
-   __func__, dssdev->name);
+   __func__, pipe->display->name);
kfree(omap_crtc);
return ERR_PTR(ret);
}
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.h 
b/drivers/gpu/drm/omapdrm/omap_crtc.h
index 1c6530703855..d9de437ba9dd 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.h
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.h
@@ -27,6 +27,7 @@ enum omap_channel;
 struct drm_crtc;
 struct drm_device;
 struct drm_plane;
+struct omap_drm_pipeline;
 struct omap_dss_device;
 struct videomode;
 
@@ -35,7 +36,8 @@ enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);
 void omap_crtc_pre_init(struct omap_drm_private *priv);
 void omap_crtc_pre_uninit(struct omap_drm_private *priv);
 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
-   struct drm_plane *plane, struct omap_dss_device *dssdev);
+   struct omap_drm_pipeline *pipe,
+   struct drm_plane *plane);
 int omap_crtc_wait_pending(struct drm_crtc *crtc);
 void omap_crtc_error_irq(struct drm_crtc *crtc, u32 irqstatus);
 void omap_crtc_vblank_irq(struct drm_crtc *crtc);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index eeecf7e7f8eb..12f72087e2cb 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -308,7 +308,7 @@ static int omap_modeset_init(struct drm_device *dev)
if (!connector)
return -ENOMEM;
 
-   crtc = omap_crtc_init(dev, priv->planes[i], display);
+   crtc = omap_crtc_init(dev, pipe, priv->planes[i]);
if (IS_ERR(crtc))
return PTR_ERR(crtc);
 
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org

[PATCH/RFC 47/60] drm/omap: dss: Get regulators at probe time

2018-03-06 Thread Laurent Pinchart
Regulators for the DPI, DSI, HDMI, SDI and VENC outputs are all looked
up when connecting the output omap_dss_device. There's no need to delay
regulator handling to that time, get the regulators at probe time.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c   | 69 ++---
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 36 ---
 drivers/gpu/drm/omapdrm/dss/hdmi4.c | 33 +-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c | 31 +
 drivers/gpu/drm/omapdrm/dss/sdi.c   | 32 +
 drivers/gpu/drm/omapdrm/dss/venc.c  | 32 +
 6 files changed, 72 insertions(+), 161 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index b60f279b3225..f51d6b97bc6e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -550,38 +550,6 @@ static int dpi_verify_pll(struct dss_pll *pll)
return 0;
 }
 
-static const struct soc_device_attribute dpi_soc_devices[] = {
-   { .machine = "OMAP3[456]*" },
-   { .machine = "[AD]M37*" },
-   { /* sentinel */ }
-};
-
-static int dpi_init_regulator(struct dpi_data *dpi)
-{
-   struct regulator *vdds_dsi;
-
-   /*
-* The DPI uses the DSI VDDS on OMAP34xx, OMAP35xx, OMAP36xx, AM37xx and
-* DM37xx only.
-*/
-   if (!soc_device_match(dpi_soc_devices))
-   return 0;
-
-   if (dpi->vdds_dsi_reg)
-   return 0;
-
-   vdds_dsi = devm_regulator_get(>pdev->dev, "vdds_dsi");
-   if (IS_ERR(vdds_dsi)) {
-   if (PTR_ERR(vdds_dsi) != -EPROBE_DEFER)
-   DSSERR("can't get VDDS_DSI regulator\n");
-   return PTR_ERR(vdds_dsi);
-   }
-
-   dpi->vdds_dsi_reg = vdds_dsi;
-
-   return 0;
-}
-
 static void dpi_init_pll(struct dpi_data *dpi)
 {
struct dss_pll *pll;
@@ -645,10 +613,6 @@ static int dpi_connect(struct omap_dss_device *dssdev,
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
int r;
 
-   r = dpi_init_regulator(dpi);
-   if (r)
-   return r;
-
dpi_init_pll(dpi);
 
r = dss_mgr_connect(dssdev);
@@ -736,6 +700,35 @@ static void dpi_uninit_output_port(struct device_node 
*port)
omapdss_device_unregister(out);
 }
 
+static const struct soc_device_attribute dpi_soc_devices[] = {
+   { .machine = "OMAP3[456]*" },
+   { .machine = "[AD]M37*" },
+   { /* sentinel */ }
+};
+
+static int dpi_init_regulator(struct dpi_data *dpi)
+{
+   struct regulator *vdds_dsi;
+
+   /*
+* The DPI uses the DSI VDDS on OMAP34xx, OMAP35xx, OMAP36xx, AM37xx and
+* DM37xx only.
+*/
+   if (!soc_device_match(dpi_soc_devices))
+   return 0;
+
+   vdds_dsi = devm_regulator_get(>pdev->dev, "vdds_dsi");
+   if (IS_ERR(vdds_dsi)) {
+   if (PTR_ERR(vdds_dsi) != -EPROBE_DEFER)
+   DSSERR("can't get VDDS_DSI regulator\n");
+   return PTR_ERR(vdds_dsi);
+   }
+
+   dpi->vdds_dsi_reg = vdds_dsi;
+
+   return 0;
+}
+
 int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
  struct device_node *port, enum dss_model dss_model)
 {
@@ -768,6 +761,10 @@ int dpi_init_port(struct dss_device *dss, struct 
platform_device *pdev,
 
mutex_init(>lock);
 
+   r = dpi_init_regulator(dpi);
+   if (r)
+   return r;
+
return dpi_init_output_port(dpi, port);
 }
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 2c2570e1ef2f..6718c7f04423 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -1137,26 +1137,6 @@ static void dsi_runtime_put(struct dsi_data *dsi)
WARN_ON(r < 0 && r != -ENOSYS);
 }
 
-static int dsi_regulator_init(struct dsi_data *dsi)
-{
-   struct regulator *vdds_dsi;
-
-   if (dsi->vdds_dsi_reg != NULL)
-   return 0;
-
-   vdds_dsi = devm_regulator_get(dsi->dev, "vdd");
-
-   if (IS_ERR(vdds_dsi)) {
-   if (PTR_ERR(vdds_dsi) != -EPROBE_DEFER)
-   DSSERR("can't get DSI VDD regulator\n");
-   return PTR_ERR(vdds_dsi);
-   }
-
-   dsi->vdds_dsi_reg = vdds_dsi;
-
-   return 0;
-}
-
 static void _dsi_print_reset_status(struct dsi_data *dsi)
 {
u32 l;
@@ -1353,10 +1333,6 @@ static int dsi_pll_enable(struct dss_pll *pll)
 
DSSDBG("PLL init\n");
 
-   r = dsi_regulator_init(dsi);
-   if (r)
-   return r;
-
r = dsi_runtime_get(dsi);
if (r)
return r;
@@ -4908,13 +4884,8 @@ static int dsi_get_clocks(struct dsi_data *dsi)
 static int dsi_connect(struct omap_dss_device *dssdev,
struct omap_dss_device *dst)
 {
-   struct dsi_data *dsi = to_dsi_data(dssdev);
int r;
 
-   r = 

[PATCH/RFC 59/60] drm/omap: Set dispc_channel_connect from DSS output connect handlers

2018-03-06 Thread Laurent Pinchart
The omap_dss_device.dispc_channel_connect field is used by DSS outputs
to fail the .enable() operation if they're not connected. Set the field
directly from the (dis)connect handlers of the DSS outputs instead of
going through the CRTC dss_mgr operations.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c   | 3 +++
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 3 +++
 drivers/gpu/drm/omapdrm/dss/hdmi4.c | 3 +++
 drivers/gpu/drm/omapdrm/dss/hdmi5.c | 3 +++
 drivers/gpu/drm/omapdrm/dss/sdi.c   | 3 +++
 drivers/gpu/drm/omapdrm/dss/venc.c  | 3 +++
 drivers/gpu/drm/omapdrm/omap_crtc.c | 3 ---
 7 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index bfbbd11baf10..00cc527483a9 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -625,12 +625,15 @@ static int dpi_connect(struct omap_dss_device *src,
return r;
}
 
+   dst->dispc_channel_connected = true;
return 0;
 }
 
 static void dpi_disconnect(struct omap_dss_device *src,
   struct omap_dss_device *dst)
 {
+   dst->dispc_channel_connected = false;
+
omapdss_device_disconnect(dst, dst->next);
 
dss_mgr_disconnect(dst);
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index bc470baa4f5c..bd5e463558be 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4896,12 +4896,15 @@ static int dsi_connect(struct omap_dss_device *src,
return r;
}
 
+   dst->dispc_channel_connected = true;
return 0;
 }
 
 static void dsi_disconnect(struct omap_dss_device *src,
   struct omap_dss_device *dst)
 {
+   dst->dispc_channel_connected = false;
+
omapdss_device_disconnect(dst, dst->next);
 
dss_mgr_disconnect(dst);
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index aa724e1925bc..3d37e3884605 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -443,12 +443,15 @@ static int hdmi_connect(struct omap_dss_device *src,
return r;
}
 
+   dst->dispc_channel_connected = true;
return 0;
 }
 
 static void hdmi_disconnect(struct omap_dss_device *src,
struct omap_dss_device *dst)
 {
+   dst->dispc_channel_connected = false;
+
omapdss_device_disconnect(dst, dst->next);
 
dss_mgr_disconnect(dst);
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 133eff60f8d8..bb905b8e052b 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -448,12 +448,15 @@ static int hdmi_connect(struct omap_dss_device *src,
return r;
}
 
+   dst->dispc_channel_connected = true;
return 0;
 }
 
 static void hdmi_disconnect(struct omap_dss_device *src,
struct omap_dss_device *dst)
 {
+   dst->dispc_channel_connected = false;
+
omapdss_device_disconnect(dst, dst->next);
 
dss_mgr_disconnect(dst);
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c 
b/drivers/gpu/drm/omapdrm/dss/sdi.c
index 09c10ba4946b..ed2595a60984 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -264,12 +264,15 @@ static int sdi_connect(struct omap_dss_device *src,
return r;
}
 
+   dst->dispc_channel_connected = true;
return 0;
 }
 
 static void sdi_disconnect(struct omap_dss_device *src,
   struct omap_dss_device *dst)
 {
+   dst->dispc_channel_connected = false;
+
omapdss_device_disconnect(dst, dst->next);
 
dss_mgr_disconnect(dst);
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c 
b/drivers/gpu/drm/omapdrm/dss/venc.c
index 997c4aebd560..4f20183c7861 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -706,12 +706,15 @@ static int venc_connect(struct omap_dss_device *src,
return r;
}
 
+   dst->dispc_channel_connected = true;
return 0;
 }
 
 static void venc_disconnect(struct omap_dss_device *src,
struct omap_dss_device *dst)
 {
+   dst->dispc_channel_connected = false;
+
omapdss_device_disconnect(dst, dst->next);
 
dss_mgr_disconnect(dst);
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 90917d040ddb..7f837697e76c 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -114,8 +114,6 @@ static int omap_crtc_dss_connect(struct omap_drm_private 
*priv,
enum omap_channel channel,
struct omap_dss_device *dst)
 {
-   dst->dispc_channel_connected = true;
-
return 0;
 }
 
@@ -123,7 

[PATCH/RFC 56/60] drm/omap: Store CRTC lookup by channel table in omap_drm_private

2018-03-06 Thread Laurent Pinchart
The omap_crtcs global array is used to store pointers to omap_crtc
indexed by DISPC channel number, in order to look them up in the dss_mgr
operations. Store the information in the omap_drm_private structure in
the form of an array of omap_drm_pipeline pointers.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 22 +-
 drivers/gpu/drm/omapdrm/omap_drv.c  | 19 +++
 drivers/gpu/drm/omapdrm/omap_drv.h  |  1 +
 3 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index f5bdb8de98f4..9742d9f49a7c 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -109,7 +109,6 @@ 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: */
@@ -215,7 +214,8 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, 
bool enable)
 static int omap_crtc_dss_enable(struct omap_drm_private *priv,
enum omap_channel channel)
 {
-   struct omap_crtc *omap_crtc = omap_crtcs[channel];
+   struct drm_crtc *crtc = priv->channels[channel]->crtc;
+   struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 
priv->dispc_ops->mgr_set_timings(priv->dispc, omap_crtc->channel,
 _crtc->vm);
@@ -227,7 +227,8 @@ static int omap_crtc_dss_enable(struct omap_drm_private 
*priv,
 static void omap_crtc_dss_disable(struct omap_drm_private *priv,
  enum omap_channel channel)
 {
-   struct omap_crtc *omap_crtc = omap_crtcs[channel];
+   struct drm_crtc *crtc = priv->channels[channel]->crtc;
+   struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 
omap_crtc_set_enabled(_crtc->base, false);
 }
@@ -236,7 +237,9 @@ static void omap_crtc_dss_set_timings(struct 
omap_drm_private *priv,
enum omap_channel channel,
const struct videomode *vm)
 {
-   struct omap_crtc *omap_crtc = omap_crtcs[channel];
+   struct drm_crtc *crtc = priv->channels[channel]->crtc;
+   struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+
DBG("%s", omap_crtc->name);
omap_crtc->vm = *vm;
 }
@@ -245,7 +248,8 @@ static void omap_crtc_dss_set_lcd_config(struct 
omap_drm_private *priv,
enum omap_channel channel,
const struct dss_lcd_mgr_config *config)
 {
-   struct omap_crtc *omap_crtc = omap_crtcs[channel];
+   struct drm_crtc *crtc = priv->channels[channel]->crtc;
+   struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 
DBG("%s", omap_crtc->name);
priv->dispc_ops->mgr_set_lcd_config(priv->dispc, omap_crtc->channel,
@@ -681,8 +685,6 @@ static const char *channel_names[] = {
 
 void omap_crtc_pre_init(struct omap_drm_private *priv)
 {
-   memset(omap_crtcs, 0, sizeof(omap_crtcs));
-
dss_install_mgr_ops(priv->dss, _ops, priv);
 }
 
@@ -706,10 +708,6 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 
DBG("%s", channel_names[channel]);
 
-   /* Multiple displays on same channel is not allowed */
-   if (WARN_ON(omap_crtcs[channel] != NULL))
-   return ERR_PTR(-EINVAL);
-
omap_crtc = kzalloc(sizeof(*omap_crtc), GFP_KERNEL);
if (!omap_crtc)
return ERR_PTR(-ENOMEM);
@@ -748,7 +746,5 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 
omap_plane_install_properties(crtc->primary, >base);
 
-   omap_crtcs[channel] = omap_crtc;
-
return crtc;
 }
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 12f72087e2cb..f3ae847c98a5 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -167,6 +167,8 @@ static void omap_disconnect_pipelines(struct drm_device 
*ddev)
pipe->display = NULL;
}
 
+   memset(>channels, 0, sizeof(priv->channels));
+
priv->num_pipes = 0;
 }
 
@@ -186,6 +188,7 @@ static int omap_connect_pipelines(struct drm_device *ddev)
 {
struct omap_drm_private *priv = ddev->dev_private;
struct omap_dss_device *output = NULL;
+   unsigned int i;
int r;
 
if (!omapdss_stack_is_ready())
@@ -218,6 +221,22 @@ static int omap_connect_pipelines(struct drm_device *ddev)
sort(priv->pipes, priv->num_pipes, sizeof(priv->pipes[0]),
 omap_compare_pipes, NULL);
 
+   /*
+* Populate the pipeline lookup table by DISPC channel. Only one display
+* is allowed per channel.
+*/
+   for (i = 0; i < priv->num_pipes; ++i) {
+   struct omap_drm_pipeline *pipe = >pipes[i];
+   enum omap_channel channel = pipe->output->dispc_channel;
+
+ 

[PATCH/RFC 44/60] drm/omap: dss: Add for_each_dss_output() macro

2018-03-06 Thread Laurent Pinchart
Similarly to for_each_dss_display(), the for_each_dss_output() macro
iterates over all the DSS connected outputs.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/base.c| 20 ++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  9 ++---
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 96be800a0f25..519682f18d36 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -127,11 +127,13 @@ struct omap_dss_device 
*omapdss_find_device_by_port(struct device_node *src,
 
 /*
  * Search for the next device starting at @from. If display_only is true, skip
- * non-display devices. Release the reference to the @from device, and acquire
- * a reference to the returned device if found.
+ * non-display devices. If output_only is true, skip non-output devices and
+ * non-connected output devices. Release the reference to the @from device, and
+ * acquire a reference to the returned device if found.
  */
 struct omap_dss_device *omapdss_device_get_next(struct omap_dss_device *from,
-   bool display_only)
+   bool display_only,
+   bool output_only)
 {
struct omap_dss_device *dssdev;
struct list_head *list;
@@ -159,9 +161,15 @@ struct omap_dss_device *omapdss_device_get_next(struct 
omap_dss_device *from,
goto done;
}
 
-   /* Filter out non-display entries if display_only is set. */
-   if (!display_only || dssdev->driver)
-   goto done;
+   /*
+* Filter out non-display entries if display_only is set, and
+* non-output entries if output_only is set.
+*/
+   if (display_only && !dssdev->driver)
+   continue;
+   if (output_only && (!dssdev->id || !dssdev->next))
+   continue;
+   goto done;
}
 
dssdev = NULL;
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 076512628afc..f563cbce86e1 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -486,9 +486,9 @@ static inline bool omapdss_is_initialized(void)
return !!omapdss_get_dss();
 }
 
-void omapdss_display_init(struct omap_dss_device *dssdev);
 #define for_each_dss_display(d) \
-   while ((d = omapdss_device_get_next(d, true)) != NULL)
+   while ((d = omapdss_device_get_next(d, true, false)) != NULL)
+void omapdss_display_init(struct omap_dss_device *dssdev);
 
 void omapdss_device_register(struct omap_dss_device *dssdev);
 void omapdss_device_unregister(struct omap_dss_device *dssdev);
@@ -497,7 +497,8 @@ void omapdss_device_put(struct omap_dss_device *dssdev);
 struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
unsigned int port);
 struct omap_dss_device *omapdss_device_get_next(struct omap_dss_device *from,
-   bool display_only);
+   bool display_only,
+   bool output_only);
 int omapdss_device_connect(struct dss_device *dss,
   struct omap_dss_device *src,
   struct omap_dss_device *dst);
@@ -509,6 +510,8 @@ int omap_dss_get_num_overlay_managers(void);
 
 int omap_dss_get_num_overlays(void);
 
+#define for_each_dss_output(d) \
+   while ((d = omapdss_device_get_next(d, false, true)) != NULL)
 int omapdss_output_set_device(struct omap_dss_device *out,
struct omap_dss_device *dssdev);
 int omapdss_output_unset_device(struct omap_dss_device *out);
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 50/60] drm/omap: Group CRTC, encoder, connector and dssdev in a structure

2018-03-06 Thread Laurent Pinchart
Create an omap_drm_pipeline structure to model display pipelines, made
of a CRTC, an encoder, a connector and a DSS display device. This allows
grouping related parameters together instead of storing them in
independent arrays and thus improves code readability.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c  |   4 +-
 drivers/gpu/drm/omapdrm/omap_drv.c   | 144 +--
 drivers/gpu/drm/omapdrm/omap_drv.h   |  20 +++--
 drivers/gpu/drm/omapdrm/omap_fbdev.c |   4 +-
 drivers/gpu/drm/omapdrm/omap_irq.c   |   4 +-
 5 files changed, 84 insertions(+), 92 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index c5f1915aef67..f5bf553a862f 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -474,8 +474,8 @@ static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc)
 * has been changed to the DRM model.
 */
 
-   for (i = 0; i < priv->num_encoders; ++i) {
-   struct drm_encoder *encoder = priv->encoders[i];
+   for (i = 0; i < priv->num_pipes; ++i) {
+   struct drm_encoder *encoder = priv->pipes[i].encoder;
 
if (encoder->crtc == crtc) {
struct omap_dss_device *dssdev;
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index d4952df6b749..d3c74e05834a 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -129,9 +129,9 @@ static const struct drm_mode_config_funcs 
omap_mode_config_funcs = {
.atomic_commit = drm_atomic_helper_commit,
 };
 
-static int get_connector_type(struct omap_dss_device *dssdev)
+static int get_connector_type(struct omap_dss_device *display)
 {
-   switch (dssdev->type) {
+   switch (display->type) {
case OMAP_DISPLAY_TYPE_HDMI:
return DRM_MODE_CONNECTOR_HDMIA;
case OMAP_DISPLAY_TYPE_DVI:
@@ -151,65 +151,65 @@ static int get_connector_type(struct omap_dss_device 
*dssdev)
}
 }
 
-static void omap_disconnect_dssdevs(struct drm_device *ddev)
+static void omap_disconnect_pipelines(struct drm_device *ddev)
 {
struct omap_drm_private *priv = ddev->dev_private;
unsigned int i;
 
-   for (i = 0; i < priv->num_dssdevs; i++) {
-   struct omap_dss_device *dssdev = priv->dssdevs[i];
+   for (i = 0; i < priv->num_pipes; i++) {
+   struct omap_dss_device *display = priv->pipes[i].display;
 
-   omapdss_device_disconnect(dssdev, NULL);
-   priv->dssdevs[i] = NULL;
-   omapdss_device_put(dssdev);
+   omapdss_device_disconnect(display, NULL);
+   priv->pipes[i].display = NULL;
+   omapdss_device_put(display);
}
 
-   priv->num_dssdevs = 0;
+   priv->num_pipes = 0;
 }
 
-static int omap_compare_dssdevs(const void *a, const void *b)
+static int omap_compare_pipes(const void *a, const void *b)
 {
-   const struct omap_dss_device *dssdev1 = *(struct omap_dss_device **)a;
-   const struct omap_dss_device *dssdev2 = *(struct omap_dss_device **)b;
+   const struct omap_drm_pipeline *pipe1 = a;
+   const struct omap_drm_pipeline *pipe2 = b;
 
-   if (dssdev1->alias_id > dssdev2->alias_id)
+   if (pipe1->display->alias_id > pipe2->display->alias_id)
return 1;
-   else if (dssdev1->alias_id < dssdev2->alias_id)
+   else if (pipe1->display->alias_id < pipe2->display->alias_id)
return -1;
return 0;
 }
 
-static int omap_connect_dssdevs(struct drm_device *ddev)
+static int omap_connect_pipelines(struct drm_device *ddev)
 {
struct omap_drm_private *priv = ddev->dev_private;
-   struct omap_dss_device *dssdev = NULL;
+   struct omap_dss_device *display = NULL;
int r;
 
if (!omapdss_stack_is_ready())
return -EPROBE_DEFER;
 
-   for_each_dss_display(dssdev) {
-   r = omapdss_device_connect(priv->dss, dssdev, NULL);
+   for_each_dss_display(display) {
+   r = omapdss_device_connect(priv->dss, display, NULL);
if (r == -EPROBE_DEFER) {
-   omapdss_device_put(dssdev);
+   omapdss_device_put(display);
goto cleanup;
} else if (r) {
-   dev_warn(dssdev->dev, "could not connect display: %s\n",
-   dssdev->name);
+   dev_warn(display->dev, "could not connect display: 
%s\n",
+   display->name);
} else {
-   omapdss_device_get(dssdev);
-   priv->dssdevs[priv->num_dssdevs++] = dssdev;
-   if (priv->num_dssdevs == ARRAY_SIZE(priv->dssdevs)) {
+   omapdss_device_get(display);
+ 

[PATCH/RFC 40/60] drm/omap: dss: hdmi4: Move initialization code from bind to probe

2018-03-06 Thread Laurent Pinchart
There's no reason to delay initialization of most of the driver (such as
mapping memory I/O or enabling runtime PM) to the component bind
handler. Perform as much of the initialization as possible at probe
time, initializing at bind time only the parts that depends on the DSS.
The cleanup code is moved from unbind to remove in a similar way.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/hdmi4.c | 218 +++-
 1 file changed, 117 insertions(+), 101 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 03edc7ec7e39..b56f8498fe64 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -543,53 +543,10 @@ static const struct omap_dss_device_ops hdmi_ops = {
},
 };
 
-static void hdmi_init_output(struct omap_hdmi *hdmi)
-{
-   struct omap_dss_device *out = >output;
-
-   out->dev = >pdev->dev;
-   out->id = OMAP_DSS_OUTPUT_HDMI;
-   out->output_type = OMAP_DISPLAY_TYPE_HDMI;
-   out->name = "hdmi.0";
-   out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
-   out->ops = _ops;
-   out->owner = THIS_MODULE;
-   out->of_ports = BIT(0);
-
-   omapdss_device_register(out);
-}
-
-static void hdmi_uninit_output(struct omap_hdmi *hdmi)
-{
-   struct omap_dss_device *out = >output;
-
-   omapdss_device_unregister(out);
-}
-
-static int hdmi_probe_of(struct omap_hdmi *hdmi)
-{
-   struct platform_device *pdev = hdmi->pdev;
-   struct device_node *node = pdev->dev.of_node;
-   struct device_node *ep;
-   int r;
-
-   ep = of_graph_get_endpoint_by_regs(node, 0, 0);
-   if (!ep)
-   return 0;
-
-   r = hdmi_parse_lanes_of(pdev, ep, >phy);
-   if (r)
-   goto err;
-
-   of_node_put(ep);
-   return 0;
-
-err:
-   of_node_put(ep);
-   return r;
-}
+/* 
-
+ * Audio Callbacks
+ */
 
-/* Audio callbacks */
 static int hdmi_audio_startup(struct device *dev,
  void (*abort_cb)(struct device *dev))
 {
@@ -704,27 +661,123 @@ static int hdmi_audio_register(struct omap_hdmi *hdmi)
return 0;
 }
 
-/* HDMI HW IP initialisation */
+/* 
-
+ * Component Bind & Unbind
+ */
+
 static int hdmi4_bind(struct device *dev, struct device *master, void *data)
 {
-   struct platform_device *pdev = to_platform_device(dev);
struct dss_device *dss = dss_get_device(master);
-   struct omap_hdmi *hdmi;
+   struct omap_hdmi *hdmi = dev_get_drvdata(dev);
int r;
+
+   hdmi->dss = dss;
+
+   r = hdmi_pll_init(dss, hdmi->pdev, >pll, >wp);
+   if (r)
+   return r;
+
+   r = hdmi4_cec_init(hdmi->pdev, >core, >wp);
+   if (r)
+   goto err_pll_uninit;
+
+   r = hdmi_audio_register(hdmi);
+   if (r) {
+   DSSERR("Registering HDMI audio failed\n");
+   goto err_cec_uninit;
+   }
+
+   hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
+  hdmi);
+
+   return 0;
+
+err_cec_uninit:
+   hdmi4_cec_uninit(>core);
+err_pll_uninit:
+   hdmi_pll_uninit(>pll);
+   return r;
+}
+
+static void hdmi4_unbind(struct device *dev, struct device *master, void *data)
+{
+   struct omap_hdmi *hdmi = dev_get_drvdata(dev);
+
+   dss_debugfs_remove_file(hdmi->debugfs);
+
+   if (hdmi->audio_pdev)
+   platform_device_unregister(hdmi->audio_pdev);
+
+   hdmi4_cec_uninit(>core);
+   hdmi_pll_uninit(>pll);
+}
+
+static const struct component_ops hdmi4_component_ops = {
+   .bind   = hdmi4_bind,
+   .unbind = hdmi4_unbind,
+};
+
+/* 
-
+ * Probe & Remove, Suspend & Resume
+ */
+
+static void hdmi4_init_output(struct omap_hdmi *hdmi)
+{
+   struct omap_dss_device *out = >output;
+
+   out->dev = >pdev->dev;
+   out->id = OMAP_DSS_OUTPUT_HDMI;
+   out->output_type = OMAP_DISPLAY_TYPE_HDMI;
+   out->name = "hdmi.0";
+   out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
+   out->ops = _ops;
+   out->owner = THIS_MODULE;
+   out->of_ports = BIT(0);
+
+   omapdss_device_register(out);
+}
+
+static void hdmi4_uninit_output(struct omap_hdmi *hdmi)
+{
+   struct omap_dss_device *out = >output;
+
+   omapdss_device_unregister(out);
+}
+
+static int hdmi4_probe_of(struct omap_hdmi *hdmi)
+{
+   struct platform_device *pdev = hdmi->pdev;
+   struct device_node *node = pdev->dev.of_node;
+   struct device_node *ep;
+   int r;
+
+   ep = of_graph_get_endpoint_by_regs(node, 0, 0);
+   if (!ep)
+   return 0;
+
+   r = hdmi_parse_lanes_of(pdev, ep, 

[PATCH/RFC 35/60] drm/omap: dss: Replace omap_dss_device port number with bitmask

2018-03-06 Thread Laurent Pinchart
The omap_dss_device port_num field stores the DT port number associated
with the device. The field is used in different ways depending on the
device type:

- For DPI outputs, the port number is used as an identifier of the DPI
instance

- For sources, the port number is used to look up the omap_dss_device by
DT port node

As omap_dss_device instances are only looked up as sources by sinks,
setting the field to the number of the source port works for both use
cases.

However, to enable looking up sinks, we need to record all the ports
associated with an omap_dss_device. Do so by turning the port_num field
into an of_ports bitmask. For DPI outputs the port number is
additionally stored in the dpi_data structure as the output ID.

Signed-off-by: Laurent Pinchart 
---
 .../gpu/drm/omapdrm/displays/connector-analog-tv.c|  1 +
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c  |  1 +
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c |  1 +
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c |  1 +
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c |  2 +-
 drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c  |  2 +-
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c  |  1 +
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  1 +
 .../drm/omapdrm/displays/panel-lgphilips-lb035q02.c   |  1 +
 .../gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c   |  1 +
 .../drm/omapdrm/displays/panel-sharp-ls037v7dw01.c|  1 +
 .../gpu/drm/omapdrm/displays/panel-sony-acx565akm.c   |  1 +
 .../gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c   |  1 +
 .../gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c   |  1 +
 drivers/gpu/drm/omapdrm/dss/base.c|  2 +-
 drivers/gpu/drm/omapdrm/dss/dpi.c | 19 +--
 drivers/gpu/drm/omapdrm/dss/dsi.c |  1 +
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   |  1 +
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   |  1 +
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  4 ++--
 drivers/gpu/drm/omapdrm/dss/sdi.c |  2 +-
 drivers/gpu/drm/omapdrm/dss/venc.c|  1 +
 22 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index f7250db0f3b7..b960c4d0e84d 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -169,6 +169,7 @@ static int tvc_probe(struct platform_device *pdev)
dssdev->dev = >dev;
dssdev->type = OMAP_DISPLAY_TYPE_VENC;
dssdev->owner = THIS_MODULE;
+   dssdev->of_ports = BIT(0);
 
omapdss_display_init(dssdev);
omapdss_device_register(dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index b4f84baff144..8ff674bf75e6 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -389,6 +389,7 @@ static int dvic_probe(struct platform_device *pdev)
dssdev->dev = >dev;
dssdev->type = OMAP_DISPLAY_TYPE_DVI;
dssdev->owner = THIS_MODULE;
+   dssdev->of_ports = BIT(0);
 
omapdss_display_init(dssdev);
omapdss_device_register(dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 0ec048b51fb5..439a7bb0a5f4 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -340,6 +340,7 @@ static int hdmic_probe(struct platform_device *pdev)
dssdev->dev = >dev;
dssdev->type = OMAP_DISPLAY_TYPE_HDMI;
dssdev->owner = THIS_MODULE;
+   dssdev->of_ports = BIT(0);
 
omapdss_display_init(dssdev);
omapdss_device_register(dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index 4d7f4dae2c10..eb0ebb850114 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -167,6 +167,7 @@ static int opa362_probe(struct platform_device *pdev)
dssdev->type = OMAP_DISPLAY_TYPE_VENC;
dssdev->output_type = OMAP_DISPLAY_TYPE_VENC;
dssdev->owner = THIS_MODULE;
+   dssdev->of_ports = BIT(1) | BIT(0);
 
omapdss_device_register(dssdev);
 
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index 833544d8502f..fb767d674297 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -190,7 +190,7 @@ static int tfp410_probe(struct platform_device *pdev)
dssdev->type = OMAP_DISPLAY_TYPE_DPI;
dssdev->output_type = OMAP_DISPLAY_TYPE_DVI;

[PATCH/RFC 54/60] drm/omap: dss: Merge two disconnection helpers

2018-03-06 Thread Laurent Pinchart
To simplify the pipeline disconnection handling merge the
omapdss_device_disconnect() and omapdss_output_unset_device() functions.
The device state check is now called for every device in the pipeline,
extending this sanity check coverage.

There is no need to return an error from omapdss_device_disconnect()
when the check fails, as omapdss_output_unset_device() used to do, given
that we can't prevent disconnection due to device unbinding (the return
value of omapdss_output_unset_device() is never checked in the current
code for that reason).

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/base.c|  2 ++
 drivers/gpu/drm/omapdrm/dss/dpi.c |  1 -
 drivers/gpu/drm/omapdrm/dss/dsi.c |  1 -
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   |  1 -
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   |  1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  1 -
 drivers/gpu/drm/omapdrm/dss/output.c  | 21 -
 drivers/gpu/drm/omapdrm/dss/sdi.c |  1 -
 drivers/gpu/drm/omapdrm/dss/venc.c|  1 -
 9 files changed, 2 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 3afb3d574a7b..fbb600d49ad2 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -236,6 +236,8 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
src->dst = NULL;
}
 
+   WARN_ON(dst->state != OMAP_DSS_DISPLAY_DISABLED);
+
if (dst->driver)
dst->driver->disconnect(src, dst);
else
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 3c4863e351f0..bfbbd11baf10 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -632,7 +632,6 @@ static void dpi_disconnect(struct omap_dss_device *src,
   struct omap_dss_device *dst)
 {
omapdss_device_disconnect(dst, dst->next);
-   omapdss_output_unset_device(dst);
 
dss_mgr_disconnect(dst);
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 53a32e20c3bd..bc470baa4f5c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4903,7 +4903,6 @@ static void dsi_disconnect(struct omap_dss_device *src,
   struct omap_dss_device *dst)
 {
omapdss_device_disconnect(dst, dst->next);
-   omapdss_output_unset_device(dst);
 
dss_mgr_disconnect(dst);
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 1d852928ed6f..aa724e1925bc 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -450,7 +450,6 @@ static void hdmi_disconnect(struct omap_dss_device *src,
struct omap_dss_device *dst)
 {
omapdss_device_disconnect(dst, dst->next);
-   omapdss_output_unset_device(dst);
 
dss_mgr_disconnect(dst);
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index d3752c9defe4..133eff60f8d8 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -455,7 +455,6 @@ static void hdmi_disconnect(struct omap_dss_device *src,
struct omap_dss_device *dst)
 {
omapdss_device_disconnect(dst, dst->next);
-   omapdss_output_unset_device(dst);
 
dss_mgr_disconnect(dst);
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index be59b9b28d81..fd0d0082605d 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -516,7 +516,6 @@ int omap_dss_get_num_overlays(void);
 #define for_each_dss_output(d) \
while ((d = omapdss_device_get_next(d, false, true)) != NULL)
 int omapdss_output_validate(struct omap_dss_device *out);
-int omapdss_output_unset_device(struct omap_dss_device *out);
 
 typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
 int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index be544dd48bf4..2da480be918d 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -24,8 +24,6 @@
 #include "dss.h"
 #include "omapdss.h"
 
-static DEFINE_MUTEX(output_lock);
-
 int omapdss_output_validate(struct omap_dss_device *out)
 {
if (out->next && out->output_type != out->next->type) {
@@ -37,25 +35,6 @@ int omapdss_output_validate(struct omap_dss_device *out)
 }
 EXPORT_SYMBOL(omapdss_output_validate);
 
-int omapdss_output_unset_device(struct omap_dss_device *out)
-{
-   int r = 0;
-
-   mutex_lock(_lock);
-
-   if (out->dst->state != OMAP_DSS_DISPLAY_DISABLED) {
-   dev_err(out->dev,
-   "device %s is not disabled, cannot unset device\n",
-   

[PATCH/RFC 57/60] drm/omap: Remove omap_crtc_output global array

2018-03-06 Thread Laurent Pinchart
The omap_crtc_output global array is used to look up the DSS output
device by channel. We can replace that by accessing the output device
from the pipeline if we store the pipeline pointer in the omap_crtc
structure.

The global array is also used to protect against double connection of an
output. This can't happen with the connection handling mechanism going
from DSS outputs to displays. We can thus drop that check, allowing
removal of the global array.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 9742d9f49a7c..5a56c8e02179 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -41,6 +41,7 @@ struct omap_crtc {
struct drm_crtc base;
 
const char *name;
+   struct omap_drm_pipeline *pipe;
enum omap_channel channel;
 
struct videomode vm;
@@ -108,9 +109,6 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc)
  * job of sequencing the setup of the video pipe in the proper order
  */
 
-/* ovl-mgr-id -> crtc */
-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_drm_private *priv,
enum omap_channel channel,
@@ -119,13 +117,9 @@ static int omap_crtc_dss_connect(struct omap_drm_private 
*priv,
const struct dispc_ops *dispc_ops = priv->dispc_ops;
struct dispc_device *dispc = priv->dispc;
 
-   if (omap_crtc_output[channel])
-   return -EINVAL;
-
if (!(dispc_ops->mgr_get_supported_outputs(dispc, channel) & dst->id))
return -EINVAL;
 
-   omap_crtc_output[channel] = dst;
dst->dispc_channel_connected = true;
 
return 0;
@@ -135,7 +129,6 @@ static void omap_crtc_dss_disconnect(struct 
omap_drm_private *priv,
enum omap_channel channel,
struct omap_dss_device *dst)
 {
-   omap_crtc_output[channel] = NULL;
dst->dispc_channel_connected = false;
 }
 
@@ -158,7 +151,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, 
bool enable)
if (WARN_ON(omap_crtc->enabled == enable))
return;
 
-   if (omap_crtc_output[channel]->output_type == OMAP_DISPLAY_TYPE_HDMI) {
+   if (omap_crtc->pipe->output->output_type == OMAP_DISPLAY_TYPE_HDMI) {
priv->dispc_ops->mgr_enable(priv->dispc, channel, enable);
omap_crtc->enabled = enable;
return;
@@ -716,6 +709,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 
init_waitqueue_head(_crtc->pending_wait);
 
+   omap_crtc->pipe = pipe;
omap_crtc->channel = channel;
omap_crtc->name = channel_names[channel];
 
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 38/60] drm/omap: dss: Cleanup error paths in output init functions

2018-03-06 Thread Laurent Pinchart
Rename the jump labels according to the cleanup they perform, not the
location they're accessed from, and move functions from error checks to
cleanup paths, and move reference handling to simplify cleanup.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c   | 10 ++
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  9 -
 drivers/gpu/drm/omapdrm/dss/hdmi4.c |  7 ---
 drivers/gpu/drm/omapdrm/dss/hdmi5.c |  7 ---
 drivers/gpu/drm/omapdrm/dss/sdi.c   |  7 ++-
 drivers/gpu/drm/omapdrm/dss/venc.c  |  7 +++
 6 files changed, 19 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 86bbc5798b26..dc189b717fef 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -744,15 +744,14 @@ int dpi_init_port(struct dss_device *dss, struct 
platform_device *pdev,
return 0;
 
r = of_property_read_u32(ep, "data-lines", );
+   of_node_put(ep);
if (r) {
DSSERR("failed to parse datalines\n");
-   goto err_datalines;
+   return r;
}
 
dpi->data_lines = datalines;
 
-   of_node_put(ep);
-
dpi->pdev = pdev;
dpi->dss_model = dss_model;
dpi->dss = dss;
@@ -763,11 +762,6 @@ int dpi_init_port(struct dss_device *dss, struct 
platform_device *pdev,
dpi_init_output_port(dpi, port);
 
return 0;
-
-err_datalines:
-   of_node_put(ep);
-
-   return r;
 }
 
 void dpi_uninit_port(struct device_node *port)
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index b3e50d8a7477..278094f29255 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5360,7 +5360,7 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
 
r = dsi_runtime_get(dsi);
if (r)
-   goto err_runtime_get;
+   goto err_pm_disable;
 
rev = dsi_read_reg(dsi, DSI_REVISION);
dev_dbg(dev, "OMAP DSI rev %d.%d\n",
@@ -5381,7 +5381,7 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
r = dsi_probe_of(dsi);
if (r) {
DSSERR("Invalid DSI DT data\n");
-   goto err_probe_of;
+   goto err_uninit_output;
}
 
r = of_platform_populate(dev->of_node, NULL, NULL, dev);
@@ -5404,11 +5404,10 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
 
return 0;
 
-err_probe_of:
+err_uninit_output:
dsi_uninit_output(dsi);
dsi_runtime_put(dsi);
-
-err_runtime_get:
+err_pm_disable:
pm_runtime_disable(dev);
return r;
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 78f0666e25f3..03edc7ec7e39 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -770,9 +770,7 @@ static int hdmi4_bind(struct device *dev, struct device 
*master, void *data)
r = hdmi_audio_register(hdmi);
if (r) {
DSSERR("Registering HDMI audio failed\n");
-   hdmi_uninit_output(hdmi);
-   pm_runtime_disable(>dev);
-   return r;
+   goto err_uninit_output;
}
 
hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
@@ -780,6 +778,9 @@ static int hdmi4_bind(struct device *dev, struct device 
*master, void *data)
 
return 0;
 
+err_uninit_output:
+   hdmi_uninit_output(hdmi);
+   pm_runtime_disable(>dev);
 err_pll:
hdmi_pll_uninit(>pll);
 err_free:
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index dd0aa63d3ace..eaefd45699a6 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -763,9 +763,7 @@ static int hdmi5_bind(struct device *dev, struct device 
*master, void *data)
r = hdmi_audio_register(hdmi);
if (r) {
DSSERR("Registering HDMI audio failed %d\n", r);
-   hdmi_uninit_output(hdmi);
-   pm_runtime_disable(>dev);
-   return r;
+   goto err_uninit_output;
}
 
hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
@@ -773,6 +771,9 @@ static int hdmi5_bind(struct device *dev, struct device 
*master, void *data)
 
return 0;
 
+err_uninit_output:
+   hdmi_uninit_output(hdmi);
+   pm_runtime_disable(>dev);
 err_pll:
hdmi_pll_uninit(>pll);
 err_free:
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c 
b/drivers/gpu/drm/omapdrm/dss/sdi.c
index fd5320041911..0ace553a21c5 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -355,16 +355,15 @@ int sdi_init_port(struct dss_device *dss, struct 
platform_device *pdev,
}
 
r = of_property_read_u32(ep, 

Re: [Intel-gfx] [PATCH] drm/dp: Correctly mask DP_TRAINING_AUX_RD_INTERVAL values for DP 1.4

2018-03-06 Thread Pandiyan, Dhinakaran



On Tue, 2018-03-06 at 15:24 -0800, Rodrigo Vivi wrote:
> On Tue, Mar 06, 2018 at 10:37:48AM -0800, matthew.s.atw...@intel.com wrote:
> > From: Matt Atwood 
> > 
> > DP_TRAINING_AUX_RD_INTERVAL with DP 1.3 spec changed bit scheme from 8
> > bits to 7 bits in DPCD 0x000e. The 8th bit describes a new feature, for
> > panels that use this new feature, this would cause a wait interval for
> > clock recovery of at least 512 ms, much higher then spec maximum of 16 ms.
> > This behavior is described in table 2-158 of DP 1.4 spec address Eh.
> > To avoid breaking panels 

See comment below:

> that are not spec compliant we now warn on
> > invalid values.
> > 
> > V2: commit title/message, masking all 7 bits, warn on out of spec values.
> 
> this approach is even better imho.
> 
> > 
> > Signed-off-by: Matt Atwood 
> 
> Reviewed-by: Rodrigo Vivi 
> 
> > ---
> >  drivers/gpu/drm/drm_dp_helper.c | 18 ++
> >  include/drm/drm_dp_helper.h |  1 +
> >  2 files changed, 15 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_dp_helper.c 
> > b/drivers/gpu/drm/drm_dp_helper.c
> > index adf79be..a718ccc 100644
> > --- a/drivers/gpu/drm/drm_dp_helper.c
> > +++ b/drivers/gpu/drm/drm_dp_helper.c
> > @@ -119,18 +119,28 @@ u8 drm_dp_get_adjust_request_pre_emphasis(const u8 
> > link_status[DP_LINK_STATUS_SI
> >  EXPORT_SYMBOL(drm_dp_get_adjust_request_pre_emphasis);
> >  
> >  void drm_dp_link_train_clock_recovery_delay(const u8 
> > dpcd[DP_RECEIVER_CAP_SIZE]) {
> > -   if (dpcd[DP_TRAINING_AUX_RD_INTERVAL] == 0)
> > +   int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & 
> > DP_TRAINING_AUX_RD_MASK;
> > +
> > +   if (rd_interval > 4)
> > +   DRM_DEBUG_KMS("AUX interval %d, out of range (max 4)", 
> > rd_interval);

Some default for panels without a valid value?
rd_interval = 4;
"AUX read interval out of range, using max %d ms"

  
> > +
> > +   if (rd_interval == 0)
> > udelay(100);
> > else
> > -   mdelay(dpcd[DP_TRAINING_AUX_RD_INTERVAL] * 4);
> > +   mdelay(rd_interval * 4);
> >  }
> >  EXPORT_SYMBOL(drm_dp_link_train_clock_recovery_delay);
> >  
> >  void drm_dp_link_train_channel_eq_delay(const u8 
> > dpcd[DP_RECEIVER_CAP_SIZE]) {
> > -   if (dpcd[DP_TRAINING_AUX_RD_INTERVAL] == 0)
> > +   int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & 
> > DP_TRAINING_AUX_RD_MASK;
> > +
> > +   if (rd_interval > 4)
> > +   DRM_DEBUG_KMS("AUX interval %d, out of range (max 4)", 
> > rd_interval);
> > +
> > +   if (rd_interval == 0)
> > udelay(400);
> > else
> > -   mdelay(dpcd[DP_TRAINING_AUX_RD_INTERVAL] * 4);
> > +   mdelay(rd_interval * 4);
> >  }
> >  EXPORT_SYMBOL(drm_dp_link_train_channel_eq_delay);
> >  
> > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> > index da58a42..f80acf1 100644
> > --- a/include/drm/drm_dp_helper.h
> > +++ b/include/drm/drm_dp_helper.h
> > @@ -118,6 +118,7 @@
> >  # define DP_DPCD_DISPLAY_CONTROL_CAPABLE (1 << 3) /* edp v1.2 or 
> > higher */
> >  
> >  #define DP_TRAINING_AUX_RD_INTERVAL 0x00e   /* XXX 1.2? */
> > +# define DP_TRAINING_AUX_RD_MASK0x7F /* 1.3 */
> >  
> >  #define DP_ADAPTER_CAP 0x00f   /* 1.2 */
> >  # define DP_FORCE_LOAD_SENSE_CAP   (1 << 0)
> > -- 
> > 2.7.4
> > 
> > ___
> > Intel-gfx mailing list
> > intel-...@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> ___
> Intel-gfx mailing list
> intel-...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 60/60] drm/omap: dss: Remove the dss_mgr_(dis)connect() operations

2018-03-06 Thread Laurent Pinchart
The dss_mgr .connect() and .disconnect() are implemented as no-op in
omapdrm. The operations are unneeded, remove them.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c | 10 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c | 10 +-
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   | 10 +-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   | 10 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  9 -
 drivers/gpu/drm/omapdrm/dss/output.c  | 14 --
 drivers/gpu/drm/omapdrm/dss/sdi.c | 10 +-
 drivers/gpu/drm/omapdrm/dss/venc.c| 10 +-
 drivers/gpu/drm/omapdrm/omap_crtc.c   | 15 ---
 9 files changed, 6 insertions(+), 92 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 00cc527483a9..f60382c76114 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -615,15 +615,9 @@ static int dpi_connect(struct omap_dss_device *src,
 
dpi_init_pll(dpi);
 
-   r = dss_mgr_connect(dst);
-   if (r)
-   return r;
-
r = omapdss_device_connect(dst->dss, dst, dst->next);
-   if (r) {
-   dss_mgr_disconnect(dst);
+   if (r)
return r;
-   }
 
dst->dispc_channel_connected = true;
return 0;
@@ -635,8 +629,6 @@ static void dpi_disconnect(struct omap_dss_device *src,
dst->dispc_channel_connected = false;
 
omapdss_device_disconnect(dst, dst->next);
-
-   dss_mgr_disconnect(dst);
 }
 
 static const struct omap_dss_device_ops dpi_ops = {
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index bd5e463558be..6fe9e2b78144 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4886,15 +4886,9 @@ static int dsi_connect(struct omap_dss_device *src,
 {
int r;
 
-   r = dss_mgr_connect(dst);
-   if (r)
-   return r;
-
r = omapdss_device_connect(dst->dss, dst, dst->next);
-   if (r) {
-   dss_mgr_disconnect(dst);
+   if (r)
return r;
-   }
 
dst->dispc_channel_connected = true;
return 0;
@@ -4906,8 +4900,6 @@ static void dsi_disconnect(struct omap_dss_device *src,
dst->dispc_channel_connected = false;
 
omapdss_device_disconnect(dst, dst->next);
-
-   dss_mgr_disconnect(dst);
 }
 
 static const struct omap_dss_device_ops dsi_ops = {
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 3d37e3884605..2c29219bf1b6 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -433,15 +433,9 @@ static int hdmi_connect(struct omap_dss_device *src,
 {
int r;
 
-   r = dss_mgr_connect(dst);
-   if (r)
-   return r;
-
r = omapdss_device_connect(dst->dss, dst, dst->next);
-   if (r) {
-   dss_mgr_disconnect(dst);
+   if (r)
return r;
-   }
 
dst->dispc_channel_connected = true;
return 0;
@@ -453,8 +447,6 @@ static void hdmi_disconnect(struct omap_dss_device *src,
dst->dispc_channel_connected = false;
 
omapdss_device_disconnect(dst, dst->next);
-
-   dss_mgr_disconnect(dst);
 }
 
 static int hdmi_read_edid(struct omap_dss_device *dssdev,
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index bb905b8e052b..7ae0c47145b0 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -438,15 +438,9 @@ static int hdmi_connect(struct omap_dss_device *src,
 {
int r;
 
-   r = dss_mgr_connect(dst);
-   if (r)
-   return r;
-
r = omapdss_device_connect(dst->dss, dst, dst->next);
-   if (r) {
-   dss_mgr_disconnect(dst);
+   if (r)
return r;
-   }
 
dst->dispc_channel_connected = true;
return 0;
@@ -458,8 +452,6 @@ static void hdmi_disconnect(struct omap_dss_device *src,
dst->dispc_channel_connected = false;
 
omapdss_device_disconnect(dst, dst->next);
-
-   dss_mgr_disconnect(dst);
 }
 
 static int hdmi_read_edid(struct omap_dss_device *dssdev,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 004195829b4f..e082e7c30a5f 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -548,13 +548,6 @@ enum dss_writeback_channel {
 };
 
 struct dss_mgr_ops {
-   int (*connect)(struct omap_drm_private *priv,
-  enum omap_channel channel,
-  struct omap_dss_device *dst);
-   void (*disconnect)(struct omap_drm_private *priv,
-  enum omap_channel channel,
-  struct omap_dss_device *dst);
-
void (*start_update)(struct omap_drm_private *priv,
  

[PATCH/RFC 41/60] drm/omap: dss: hdmi5: Move initialization code from bind to probe

2018-03-06 Thread Laurent Pinchart
There's no reason to delay initialization of most of the driver (such as
mapping memory I/O or enabling runtime PM) to the component bind
handler. Perform as much of the initialization as possible at probe
time, initializing at bind time only the parts that depends on the DSS.
The cleanup code is moved from unbind to remove in a similar way.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/hdmi5.c | 205 +++-
 1 file changed, 110 insertions(+), 95 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index eaefd45699a6..767727677f9a 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -534,53 +534,10 @@ static const struct omap_dss_device_ops hdmi_ops = {
},
 };
 
-static void hdmi_init_output(struct omap_hdmi *hdmi)
-{
-   struct omap_dss_device *out = >output;
-
-   out->dev = >pdev->dev;
-   out->id = OMAP_DSS_OUTPUT_HDMI;
-   out->output_type = OMAP_DISPLAY_TYPE_HDMI;
-   out->name = "hdmi.0";
-   out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
-   out->ops = _ops;
-   out->owner = THIS_MODULE;
-   out->of_ports = BIT(0);
-
-   omapdss_device_register(out);
-}
-
-static void hdmi_uninit_output(struct omap_hdmi *hdmi)
-{
-   struct omap_dss_device *out = >output;
-
-   omapdss_device_unregister(out);
-}
-
-static int hdmi_probe_of(struct omap_hdmi *hdmi)
-{
-   struct platform_device *pdev = hdmi->pdev;
-   struct device_node *node = pdev->dev.of_node;
-   struct device_node *ep;
-   int r;
-
-   ep = of_graph_get_endpoint_by_regs(node, 0, 0);
-   if (!ep)
-   return 0;
-
-   r = hdmi_parse_lanes_of(pdev, ep, >phy);
-   if (r)
-   goto err;
-
-   of_node_put(ep);
-   return 0;
-
-err:
-   of_node_put(ep);
-   return r;
-}
+/* 
-
+ * Audio Callbacks
+ */
 
-/* Audio callbacks */
 static int hdmi_audio_startup(struct device *dev,
  void (*abort_cb)(struct device *dev))
 {
@@ -701,27 +658,116 @@ static int hdmi_audio_register(struct omap_hdmi *hdmi)
return 0;
 }
 
-/* HDMI HW IP initialisation */
+/* 
-
+ * Component Bind & Unbind
+ */
+
 static int hdmi5_bind(struct device *dev, struct device *master, void *data)
 {
-   struct platform_device *pdev = to_platform_device(dev);
struct dss_device *dss = dss_get_device(master);
-   struct omap_hdmi *hdmi;
+   struct omap_hdmi *hdmi = dev_get_drvdata(dev);
int r;
+
+   hdmi->dss = dss;
+
+   r = hdmi_pll_init(dss, hdmi->pdev, >pll, >wp);
+   if (r)
+   return r;
+
+   r = hdmi_audio_register(hdmi);
+   if (r) {
+   DSSERR("Registering HDMI audio failed %d\n", r);
+   goto err_pll_uninit;
+   }
+
+   hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
+   hdmi);
+
+   return 0;
+
+err_pll_uninit:
+   hdmi_pll_uninit(>pll);
+   return r;
+}
+
+static void hdmi5_unbind(struct device *dev, struct device *master, void *data)
+{
+   struct omap_hdmi *hdmi = dev_get_drvdata(dev);
+
+   dss_debugfs_remove_file(hdmi->debugfs);
+
+   if (hdmi->audio_pdev)
+   platform_device_unregister(hdmi->audio_pdev);
+
+   hdmi_pll_uninit(>pll);
+}
+
+static const struct component_ops hdmi5_component_ops = {
+   .bind   = hdmi5_bind,
+   .unbind = hdmi5_unbind,
+};
+
+/* 
-
+ * Probe & Remove, Suspend & Resume
+ */
+
+static void hdmi5_init_output(struct omap_hdmi *hdmi)
+{
+   struct omap_dss_device *out = >output;
+
+   out->dev = >pdev->dev;
+   out->id = OMAP_DSS_OUTPUT_HDMI;
+   out->output_type = OMAP_DISPLAY_TYPE_HDMI;
+   out->name = "hdmi.0";
+   out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
+   out->ops = _ops;
+   out->owner = THIS_MODULE;
+   out->of_ports = BIT(0);
+
+   omapdss_device_register(out);
+}
+
+static void hdmi5_uninit_output(struct omap_hdmi *hdmi)
+{
+   struct omap_dss_device *out = >output;
+
+   omapdss_device_unregister(out);
+}
+
+static int hdmi5_probe_of(struct omap_hdmi *hdmi)
+{
+   struct platform_device *pdev = hdmi->pdev;
+   struct device_node *node = pdev->dev.of_node;
+   struct device_node *ep;
+   int r;
+
+   ep = of_graph_get_endpoint_by_regs(node, 0, 0);
+   if (!ep)
+   return 0;
+
+   r = hdmi_parse_lanes_of(pdev, ep, >phy);
+   of_node_put(ep);
+   return r;
+}
+
+static int hdmi5_probe(struct platform_device *pdev)
+{
+   struct omap_hdmi *hdmi;
int irq;
+   int r;
 

[PATCH/RFC 48/60] drm/omap: Remove unneeded variable assignments in omap_modeset_init

2018-03-06 Thread Laurent Pinchart
The crtc_idx and plane_idw variables in the main loop are always equal
to the loop counter i, use it instead. Don't unnecessarily initialize
dssdev to NULL.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 18 +-
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 471a04faaf0f..902f65e9eb63 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -239,10 +239,9 @@ static int omap_modeset_init_properties(struct drm_device 
*dev)
 static int omap_modeset_init(struct drm_device *dev)
 {
struct omap_drm_private *priv = dev->dev_private;
-   struct omap_dss_device *dssdev = NULL;
int num_ovls = priv->dispc_ops->get_num_ovls(priv->dispc);
int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
-   int num_crtcs, crtc_idx, plane_idx;
+   int num_crtcs;
unsigned int i;
int ret;
u32 plane_crtc_mask;
@@ -275,10 +274,6 @@ static int omap_modeset_init(struct drm_device *dev)
/* All planes can be put to any CRTC */
plane_crtc_mask = (1 << num_crtcs) - 1;
 
-   dssdev = NULL;
-
-   crtc_idx = 0;
-   plane_idx = 0;
for (i = 0; i < priv->num_dssdevs; i++) {
struct omap_dss_device *dssdev = priv->dssdevs[i];
struct drm_connector *connector;
@@ -295,7 +290,7 @@ static int omap_modeset_init(struct drm_device *dev)
if (!connector)
return -ENOMEM;
 
-   plane = omap_plane_init(dev, plane_idx, DRM_PLANE_TYPE_PRIMARY,
+   plane = omap_plane_init(dev, i, DRM_PLANE_TYPE_PRIMARY,
plane_crtc_mask);
if (IS_ERR(plane))
return PTR_ERR(plane);
@@ -305,27 +300,24 @@ static int omap_modeset_init(struct drm_device *dev)
return PTR_ERR(crtc);
 
drm_mode_connector_attach_encoder(connector, encoder);
-   encoder->possible_crtcs = (1 << crtc_idx);
+   encoder->possible_crtcs = 1 << i;
 
priv->crtcs[priv->num_crtcs++] = crtc;
priv->planes[priv->num_planes++] = plane;
priv->encoders[priv->num_encoders++] = encoder;
priv->connectors[priv->num_connectors++] = connector;
-
-   plane_idx++;
-   crtc_idx++;
}
 
/*
 * Create normal planes for the remaining overlays:
 */
-   for (; plane_idx < num_ovls; plane_idx++) {
+   for (; i < num_ovls; i++) {
struct drm_plane *plane;
 
if (WARN_ON(priv->num_planes >= ARRAY_SIZE(priv->planes)))
return -EINVAL;
 
-   plane = omap_plane_init(dev, plane_idx, DRM_PLANE_TYPE_OVERLAY,
+   plane = omap_plane_init(dev, i, DRM_PLANE_TYPE_OVERLAY,
plane_crtc_mask);
if (IS_ERR(plane))
return PTR_ERR(plane);
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 45/60] drm/omap: dss: Add function to retrieve display for an output

2018-03-06 Thread Laurent Pinchart
Add a new omapdss_display_get() function to retrieve the omap_dss_device
for a given DSS output. This will be used when reversing the direction
of the DSS pipeline handling logic.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/display.c | 9 +
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/display.c 
b/drivers/gpu/drm/omapdrm/dss/display.c
index 65ca71859c7d..697dab0435d6 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -49,3 +49,12 @@ void omapdss_display_init(struct omap_dss_device *dssdev)
  "display%u", id);
 }
 EXPORT_SYMBOL_GPL(omapdss_display_init);
+
+struct omap_dss_device *omapdss_display_get(struct omap_dss_device *output)
+{
+   while (output->next)
+   output = output->next;
+
+   return omapdss_device_get(output);
+}
+EXPORT_SYMBOL_GPL(omapdss_display_get);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index f563cbce86e1..14aebef5dc3a 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -489,6 +489,7 @@ static inline bool omapdss_is_initialized(void)
 #define for_each_dss_display(d) \
while ((d = omapdss_device_get_next(d, true, false)) != NULL)
 void omapdss_display_init(struct omap_dss_device *dssdev);
+struct omap_dss_device *omapdss_display_get(struct omap_dss_device *output);
 
 void omapdss_device_register(struct omap_dss_device *dssdev);
 void omapdss_device_unregister(struct omap_dss_device *dssdev);
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 34/60] drm/omap: dss: Modify omapdss_find_output_from_display() to return channel

2018-03-06 Thread Laurent Pinchart
The omapdss_find_output_from_display() function is only used to retrieve
the dispc channel corresponding to the display. Return the dispc channel
directly, and rename the function to omapdss_device_get_dispc_channel()
to match its new purpose.

The dssdev->id check is removed as the dssdev is guaranteed to be an
output and have a non-zero id, as proved by the lack of crash despite
the caller never checking the returned pointer before dereferencing it.

As the function is not specific to outputs anymore, move it from
output.c to base.c.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/base.c|  9 +
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 +--
 drivers/gpu/drm/omapdrm/dss/output.c  | 12 
 drivers/gpu/drm/omapdrm/omap_crtc.c   |  5 +
 4 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index b4bc58c5134d..7f9d8a8be8c3 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -236,6 +236,15 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
 }
 EXPORT_SYMBOL_GPL(omapdss_device_disconnect);
 
+enum omap_channel omapdss_device_get_dispc_channel(struct omap_dss_device 
*dssdev)
+{
+   while (dssdev->src)
+   dssdev = dssdev->src;
+
+   return dssdev->dispc_channel;
+}
+EXPORT_SYMBOL(omapdss_device_get_dispc_channel);
+
 /* 
-
  * Components Handling
  */
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 2b616ab387aa..7489a301d761 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -502,6 +502,7 @@ int omapdss_device_connect(struct dss_device *dss,
   struct omap_dss_device *dst);
 void omapdss_device_disconnect(struct omap_dss_device *src,
   struct omap_dss_device *dst);
+enum omap_channel omapdss_device_get_dispc_channel(struct omap_dss_device 
*dssdev);
 
 int omap_dss_get_num_overlay_managers(void);
 
@@ -511,8 +512,6 @@ int omapdss_output_set_device(struct omap_dss_device *out,
struct omap_dss_device *dssdev);
 int omapdss_output_unset_device(struct omap_dss_device *out);
 
-struct omap_dss_device *omapdss_find_output_from_display(struct 
omap_dss_device *dssdev);
-
 typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
 int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
 int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index a5df6eed4aef..191b2e801257 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -88,18 +88,6 @@ int omapdss_output_unset_device(struct omap_dss_device *out)
 }
 EXPORT_SYMBOL(omapdss_output_unset_device);
 
-struct omap_dss_device *omapdss_find_output_from_display(struct 
omap_dss_device *dssdev)
-{
-   while (dssdev->src)
-   dssdev = dssdev->src;
-
-   if (dssdev->id != 0)
-   return omapdss_device_get(dssdev);
-
-   return NULL;
-}
-EXPORT_SYMBOL(omapdss_find_output_from_display);
-
 int dss_install_mgr_ops(struct dss_device *dss,
const struct dss_mgr_ops *mgr_ops,
struct omap_drm_private *priv)
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 4ddc4ed18b47..c5f1915aef67 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -699,12 +699,9 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
struct drm_crtc *crtc = NULL;
struct omap_crtc *omap_crtc;
enum omap_channel channel;
-   struct omap_dss_device *out;
int ret;
 
-   out = omapdss_find_output_from_display(dssdev);
-   channel = out->dispc_channel;
-   omapdss_device_put(out);
+   channel = omapdss_device_get_dispc_channel(dssdev);
 
DBG("%s", channel_names[channel]);
 
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 52/60] drm/omap: dss: Move connection checks to omapdss_device_(dis)connect

2018-03-06 Thread Laurent Pinchart
When a DSS output is (dis)connected the omapdss_output_(un)set_device()
function performs a sanity check to ensure that the output isn't already
(dis)connected. The check is unnecessary as those situations should
never happen, but can nonetheless be useful to catch driver bugs. To
prepare for removal of the omapdss_output_(un)set_device() functions
move the connection check to the omapdss_device_connect() function. The
omapdss_device_disconnect() already contains a corresponding check.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/base.c   |  1 +
 drivers/gpu/drm/omapdrm/dss/output.c | 29 ++---
 2 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 7f41c541397b..3afb3d574a7b 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -209,6 +209,7 @@ int omapdss_device_connect(struct dss_device *dss,
}
 
if (src) {
+   WARN_ON(src->dst);
dst->src = src;
src->dst = dst;
}
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index 2f7a019d059e..96d74218cf91 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -29,61 +29,36 @@ static DEFINE_MUTEX(output_lock);
 int omapdss_output_set_device(struct omap_dss_device *out,
struct omap_dss_device *dssdev)
 {
-   int r;
+   int r = 0;
 
mutex_lock(_lock);
 
-   if (out->dst) {
-   dev_err(out->dev,
-   "output already has device %s connected to it\n",
-   out->dst->name);
-   r = -EINVAL;
-   goto err;
-   }
-
if (out->output_type != dssdev->type) {
dev_err(out->dev, "output type and display type don't match\n");
r = -EINVAL;
-   goto err;
}
 
mutex_unlock(_lock);
 
-   return 0;
-err:
-   mutex_unlock(_lock);
-
return r;
 }
 EXPORT_SYMBOL(omapdss_output_set_device);
 
 int omapdss_output_unset_device(struct omap_dss_device *out)
 {
-   int r;
+   int r = 0;
 
mutex_lock(_lock);
 
-   if (!out->dst) {
-   dev_err(out->dev,
-   "output doesn't have a device connected to it\n");
-   r = -EINVAL;
-   goto err;
-   }
-
if (out->dst->state != OMAP_DSS_DISPLAY_DISABLED) {
dev_err(out->dev,
"device %s is not disabled, cannot unset device\n",
out->dst->name);
r = -EINVAL;
-   goto err;
}
 
mutex_unlock(_lock);
 
-   return 0;
-err:
-   mutex_unlock(_lock);
-
return r;
 }
 EXPORT_SYMBOL(omapdss_output_unset_device);
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 42/60] drm/omap: dss: venc: Move initialization code from bind to probe

2018-03-06 Thread Laurent Pinchart
There's no reason to delay initialization of most of the driver (such as
mapping memory I/O or enabling runtime PM) to the component bind
handler. Perform as much of the initialization as possible at probe
time, initializing at bind time only the parts that depends on the DSS.
The cleanup code is moved from unbind to remove in a similar way.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/venc.c | 104 +
 1 file changed, 60 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c 
b/drivers/gpu/drm/omapdrm/dss/venc.c
index c8fb91bb1ad3..84069e79ca6a 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -756,6 +756,50 @@ static const struct omap_dss_device_ops venc_ops = {
.set_timings = venc_set_timings,
 };
 
+/* 
-
+ * Component Bind & Unbind
+ */
+
+static int venc_bind(struct device *dev, struct device *master, void *data)
+{
+   struct dss_device *dss = dss_get_device(master);
+   struct venc_device *venc = dev_get_drvdata(dev);
+   u8 rev_id;
+   int r;
+
+   venc->dss = dss;
+
+   r = venc_runtime_get(venc);
+   if (r)
+   return r;
+
+   rev_id = (u8)(venc_read_reg(venc, VENC_REV_ID) & 0xff);
+   dev_dbg(dev, "OMAP VENC rev %d\n", rev_id);
+
+   venc_runtime_put(venc);
+
+   venc->debugfs = dss_debugfs_create_file(dss, "venc", venc_dump_regs,
+   venc);
+
+   return 0;
+}
+
+static void venc_unbind(struct device *dev, struct device *master, void *data)
+{
+   struct venc_device *venc = dev_get_drvdata(dev);
+
+   dss_debugfs_remove_file(venc->debugfs);
+}
+
+static const struct component_ops venc_component_ops = {
+   .bind   = venc_bind,
+   .unbind = venc_unbind,
+};
+
+/* 
-
+ * Probe & Remove, Suspend & Resume
+ */
+
 static void venc_init_output(struct venc_device *venc)
 {
struct omap_dss_device *out = >output;
@@ -820,19 +864,15 @@ static int venc_probe_of(struct venc_device *venc)
return r;
 }
 
-/* VENC HW IP initialisation */
 static const struct soc_device_attribute venc_soc_devices[] = {
{ .machine = "OMAP3[45]*" },
{ .machine = "AM35*" },
{ /* sentinel */ }
 };
 
-static int venc_bind(struct device *dev, struct device *master, void *data)
+static int venc_probe(struct platform_device *pdev)
 {
-   struct platform_device *pdev = to_platform_device(dev);
-   struct dss_device *dss = dss_get_device(master);
struct venc_device *venc;
-   u8 rev_id;
struct resource *venc_mem;
int r;
 
@@ -841,8 +881,8 @@ static int venc_bind(struct device *dev, struct device 
*master, void *data)
return -ENOMEM;
 
venc->pdev = pdev;
-   venc->dss = dss;
-   dev_set_drvdata(dev, venc);
+
+   platform_set_drvdata(pdev, venc);
 
/* The OMAP34xx, OMAP35xx and AM35xx VENC require the TV DAC clock. */
if (soc_device_match(venc_soc_devices))
@@ -863,63 +903,39 @@ static int venc_bind(struct device *dev, struct device 
*master, void *data)
if (r)
goto err_free;
 
-   pm_runtime_enable(>dev);
-
-   r = venc_runtime_get(venc);
-   if (r)
-   goto err_pm_disable;
-
-   rev_id = (u8)(venc_read_reg(venc, VENC_REV_ID) & 0xff);
-   dev_dbg(>dev, "OMAP VENC rev %d\n", rev_id);
-
-   venc_runtime_put(venc);
-
r = venc_probe_of(venc);
-   if (r) {
-   DSSERR("Invalid DT data\n");
-   goto err_pm_disable;
-   }
+   if (r)
+   goto err_free;
 
-   venc->debugfs = dss_debugfs_create_file(dss, "venc", venc_dump_regs,
-   venc);
+   pm_runtime_enable(>dev);
 
venc_init_output(venc);
 
+   r = component_add(>dev, _component_ops);
+   if (r)
+   goto err_uninit_output;
+
return 0;
 
-err_pm_disable:
+err_uninit_output:
+   venc_uninit_output(venc);
pm_runtime_disable(>dev);
 err_free:
kfree(venc);
return r;
 }
 
-static void venc_unbind(struct device *dev, struct device *master, void *data)
+static int venc_remove(struct platform_device *pdev)
 {
-   struct venc_device *venc = dev_get_drvdata(dev);
+   struct venc_device *venc = platform_get_drvdata(pdev);
 
-   dss_debugfs_remove_file(venc->debugfs);
+   component_del(>dev, _component_ops);
 
venc_uninit_output(venc);
 
-   pm_runtime_disable(dev);
+   pm_runtime_disable(>dev);
 
kfree(venc);
-}
-
-static const struct component_ops venc_component_ops = {
-   .bind   = venc_bind,
-   .unbind = venc_unbind,
-};
-
-static int venc_probe(struct platform_device 

[PATCH/RFC 46/60] drm/omap: dss: Remove duplicated parameter to dss_mgr_(dis)connect()

2018-03-06 Thread Laurent Pinchart
The dss_mgr_connect() and dss_mgr_disconnect() functions take two
omap_dss_device pointers as parameters, which are always set to the same
value by all callers. Remove the duplicated pointer.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c | 8 +++-
 drivers/gpu/drm/omapdrm/dss/dsi.c | 8 +++-
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   | 8 +++-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   | 8 +++-
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 6 ++
 drivers/gpu/drm/omapdrm/dss/output.c  | 9 -
 drivers/gpu/drm/omapdrm/dss/sdi.c | 8 +++-
 drivers/gpu/drm/omapdrm/dss/venc.c| 8 +++-
 8 files changed, 24 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index b73d7aad3d89..b60f279b3225 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -651,7 +651,7 @@ static int dpi_connect(struct omap_dss_device *dssdev,
 
dpi_init_pll(dpi);
 
-   r = dss_mgr_connect(>output, dssdev);
+   r = dss_mgr_connect(dssdev);
if (r)
return r;
 
@@ -659,7 +659,7 @@ static int dpi_connect(struct omap_dss_device *dssdev,
if (r) {
DSSERR("failed to connect output to new device: %s\n",
dst->name);
-   dss_mgr_disconnect(>output, dssdev);
+   dss_mgr_disconnect(dssdev);
return r;
}
 
@@ -669,11 +669,9 @@ static int dpi_connect(struct omap_dss_device *dssdev,
 static void dpi_disconnect(struct omap_dss_device *dssdev,
struct omap_dss_device *dst)
 {
-   struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
-
omapdss_output_unset_device(dssdev);
 
-   dss_mgr_disconnect(>output, dssdev);
+   dss_mgr_disconnect(dssdev);
 }
 
 static const struct omap_dss_device_ops dpi_ops = {
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index b48ee792244b..2c2570e1ef2f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4915,7 +4915,7 @@ static int dsi_connect(struct omap_dss_device *dssdev,
if (r)
return r;
 
-   r = dss_mgr_connect(>output, dssdev);
+   r = dss_mgr_connect(dssdev);
if (r)
return r;
 
@@ -4923,7 +4923,7 @@ static int dsi_connect(struct omap_dss_device *dssdev,
if (r) {
DSSERR("failed to connect output to new device: %s\n",
dssdev->name);
-   dss_mgr_disconnect(>output, dssdev);
+   dss_mgr_disconnect(dssdev);
return r;
}
 
@@ -4933,11 +4933,9 @@ static int dsi_connect(struct omap_dss_device *dssdev,
 static void dsi_disconnect(struct omap_dss_device *dssdev,
struct omap_dss_device *dst)
 {
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
omapdss_output_unset_device(dssdev);
 
-   dss_mgr_disconnect(>output, dssdev);
+   dss_mgr_disconnect(dssdev);
 }
 
 static const struct omap_dss_device_ops dsi_ops = {
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 8b9bb3b2b418..b01ed17f4206 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -458,7 +458,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
if (r)
return r;
 
-   r = dss_mgr_connect(>output, dssdev);
+   r = dss_mgr_connect(dssdev);
if (r)
return r;
 
@@ -466,7 +466,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
if (r) {
DSSERR("failed to connect output to new device: %s\n",
dst->name);
-   dss_mgr_disconnect(>output, dssdev);
+   dss_mgr_disconnect(dssdev);
return r;
}
 
@@ -476,11 +476,9 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
 static void hdmi_disconnect(struct omap_dss_device *dssdev,
struct omap_dss_device *dst)
 {
-   struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
-
omapdss_output_unset_device(dssdev);
 
-   dss_mgr_disconnect(>output, dssdev);
+   dss_mgr_disconnect(dssdev);
 }
 
 static int hdmi_read_edid(struct omap_dss_device *dssdev,
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 0f611b2b554a..003d6031144f 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -461,7 +461,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
if (r)
return r;
 
-   r = dss_mgr_connect(>output, dssdev);
+   r = dss_mgr_connect(dssdev);
if (r)
return r;
 
@@ -469,7 +469,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
if (r) {
DSSERR("failed to 

[PATCH/RFC 49/60] drm/omap: Create all planes before CRTCs

2018-03-06 Thread Laurent Pinchart
Creating all the planes in a single location instead of creating them
per-CRTC with remaining planes then created in a second step simplifies
the logic.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 45 --
 1 file changed, 19 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 902f65e9eb63..d4952df6b749 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -271,14 +271,30 @@ static int omap_modeset_init(struct drm_device *dev)
return -EINVAL;
}
 
-   /* All planes can be put to any CRTC */
+   /* Create all planes first. They can all be put to any CRTC. */
plane_crtc_mask = (1 << num_crtcs) - 1;
 
+   for (i = 0; i < num_ovls; i++) {
+   enum drm_plane_type type = i < priv->num_dssdevs
+? DRM_PLANE_TYPE_PRIMARY
+: DRM_PLANE_TYPE_OVERLAY;
+   struct drm_plane *plane;
+
+   if (WARN_ON(priv->num_planes >= ARRAY_SIZE(priv->planes)))
+   return -EINVAL;
+
+   plane = omap_plane_init(dev, i, type, plane_crtc_mask);
+   if (IS_ERR(plane))
+   return PTR_ERR(plane);
+
+   priv->planes[priv->num_planes++] = plane;
+   }
+
+   /* Create the CRTCs, encoders and connectors. */
for (i = 0; i < priv->num_dssdevs; i++) {
struct omap_dss_device *dssdev = priv->dssdevs[i];
struct drm_connector *connector;
struct drm_encoder *encoder;
-   struct drm_plane *plane;
struct drm_crtc *crtc;
 
encoder = omap_encoder_init(dev, dssdev);
@@ -290,12 +306,7 @@ static int omap_modeset_init(struct drm_device *dev)
if (!connector)
return -ENOMEM;
 
-   plane = omap_plane_init(dev, i, DRM_PLANE_TYPE_PRIMARY,
-   plane_crtc_mask);
-   if (IS_ERR(plane))
-   return PTR_ERR(plane);
-
-   crtc = omap_crtc_init(dev, plane, dssdev);
+   crtc = omap_crtc_init(dev, priv->planes[i], dssdev);
if (IS_ERR(crtc))
return PTR_ERR(crtc);
 
@@ -303,28 +314,10 @@ static int omap_modeset_init(struct drm_device *dev)
encoder->possible_crtcs = 1 << i;
 
priv->crtcs[priv->num_crtcs++] = crtc;
-   priv->planes[priv->num_planes++] = plane;
priv->encoders[priv->num_encoders++] = encoder;
priv->connectors[priv->num_connectors++] = connector;
}
 
-   /*
-* Create normal planes for the remaining overlays:
-*/
-   for (; i < num_ovls; i++) {
-   struct drm_plane *plane;
-
-   if (WARN_ON(priv->num_planes >= ARRAY_SIZE(priv->planes)))
-   return -EINVAL;
-
-   plane = omap_plane_init(dev, i, DRM_PLANE_TYPE_OVERLAY,
-   plane_crtc_mask);
-   if (IS_ERR(plane))
-   return PTR_ERR(plane);
-
-   priv->planes[priv->num_planes++] = plane;
-   }
-
DBG("registered %d planes, %d crtcs, %d encoders and %d connectors\n",
priv->num_planes, priv->num_crtcs, priv->num_encoders,
priv->num_connectors);
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 33/60] drm/omap: dss: Move DSS mgr ops and private data to dss_device

2018-03-06 Thread Laurent Pinchart
The DSS manager ops and private data pointer are specific to a DSS
instance. Store them in the dss_device structure instead of global
variable.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dss.h |  2 ++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  5 +--
 drivers/gpu/drm/omapdrm/dss/output.c  | 58 ---
 drivers/gpu/drm/omapdrm/omap_crtc.c   |  6 ++--
 drivers/gpu/drm/omapdrm/omap_crtc.h   |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c|  4 +--
 6 files changed, 44 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index ea850b9c5e7c..6dc2965649e8 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -266,6 +266,8 @@ struct dss_device {
 
struct dispc_device *dispc;
const struct dispc_ops *dispc_ops;
+   const struct dss_mgr_ops *mgr_ops;
+   struct omap_drm_private *mgr_ops_priv;
 };
 
 /* core */
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index d530fb938bc4..2b616ab387aa 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -572,9 +572,10 @@ struct dss_mgr_ops {
void (*handler)(void *), void *data);
 };
 
-int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops,
+int dss_install_mgr_ops(struct dss_device *dss,
+   const struct dss_mgr_ops *mgr_ops,
struct omap_drm_private *priv);
-void dss_uninstall_mgr_ops(void);
+void dss_uninstall_mgr_ops(struct dss_device *dss);
 
 int dss_mgr_connect(struct omap_dss_device *dssdev,
struct omap_dss_device *dst);
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index b5bf7a5e35d9..a5df6eed4aef 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include "dss.h"
 #include "omapdss.h"
 
 static DEFINE_MUTEX(output_lock);
@@ -99,90 +100,97 @@ struct omap_dss_device 
*omapdss_find_output_from_display(struct omap_dss_device
 }
 EXPORT_SYMBOL(omapdss_find_output_from_display);
 
-static const struct dss_mgr_ops *dss_mgr_ops;
-static struct omap_drm_private *dss_mgr_ops_priv;
-
-int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops,
+int dss_install_mgr_ops(struct dss_device *dss,
+   const struct dss_mgr_ops *mgr_ops,
struct omap_drm_private *priv)
 {
-   if (dss_mgr_ops)
+   if (dss->mgr_ops)
return -EBUSY;
 
-   dss_mgr_ops = mgr_ops;
-   dss_mgr_ops_priv = priv;
+   dss->mgr_ops = mgr_ops;
+   dss->mgr_ops_priv = priv;
 
return 0;
 }
 EXPORT_SYMBOL(dss_install_mgr_ops);
 
-void dss_uninstall_mgr_ops(void)
+void dss_uninstall_mgr_ops(struct dss_device *dss)
 {
-   dss_mgr_ops = NULL;
-   dss_mgr_ops_priv = NULL;
+   dss->mgr_ops = NULL;
+   dss->mgr_ops_priv = NULL;
 }
 EXPORT_SYMBOL(dss_uninstall_mgr_ops);
 
 int dss_mgr_connect(struct omap_dss_device *dssdev, struct omap_dss_device 
*dst)
 {
-   return dss_mgr_ops->connect(dss_mgr_ops_priv,
-   dssdev->dispc_channel, dst);
+   return dssdev->dss->mgr_ops->connect(dssdev->dss->mgr_ops_priv,
+dssdev->dispc_channel, dst);
 }
 EXPORT_SYMBOL(dss_mgr_connect);
 
 void dss_mgr_disconnect(struct omap_dss_device *dssdev,
struct omap_dss_device *dst)
 {
-   dss_mgr_ops->disconnect(dss_mgr_ops_priv, dssdev->dispc_channel, dst);
+   dssdev->dss->mgr_ops->disconnect(dssdev->dss->mgr_ops_priv,
+dssdev->dispc_channel, dst);
 }
 EXPORT_SYMBOL(dss_mgr_disconnect);
 
 void dss_mgr_set_timings(struct omap_dss_device *dssdev,
 const struct videomode *vm)
 {
-   dss_mgr_ops->set_timings(dss_mgr_ops_priv, dssdev->dispc_channel, vm);
+   dssdev->dss->mgr_ops->set_timings(dssdev->dss->mgr_ops_priv,
+ dssdev->dispc_channel, vm);
 }
 EXPORT_SYMBOL(dss_mgr_set_timings);
 
 void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
const struct dss_lcd_mgr_config *config)
 {
-   dss_mgr_ops->set_lcd_config(dss_mgr_ops_priv,
-   dssdev->dispc_channel, config);
+   dssdev->dss->mgr_ops->set_lcd_config(dssdev->dss->mgr_ops_priv,
+dssdev->dispc_channel, config);
 }
 EXPORT_SYMBOL(dss_mgr_set_lcd_config);
 
 int dss_mgr_enable(struct omap_dss_device *dssdev)
 {
-   return dss_mgr_ops->enable(dss_mgr_ops_priv, dssdev->dispc_channel);
+   return dssdev->dss->mgr_ops->enable(dssdev->dss->mgr_ops_priv,
+   dssdev->dispc_channel);
 }
 EXPORT_SYMBOL(dss_mgr_enable);
 

[PATCH/RFC 22/60] drm/omap: dss: Move src and dst check and set to connection handlers

2018-03-06 Thread Laurent Pinchart
The encoders duplicate the same omap_dss_device src and dst fields set
and checks in their connect and disconnect handlers. Move the code to
the connect and disconnect wrappers.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c  | 10 -
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c  | 10 -
 .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c   | 11 --
 drivers/gpu/drm/omapdrm/dss/base.c | 24 --
 drivers/gpu/drm/omapdrm/dss/dpi.c  |  5 -
 drivers/gpu/drm/omapdrm/dss/dsi.c  |  5 -
 drivers/gpu/drm/omapdrm/dss/hdmi4.c|  5 -
 drivers/gpu/drm/omapdrm/dss/hdmi5.c|  5 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  8 +++-
 drivers/gpu/drm/omapdrm/dss/output.c   |  6 --
 drivers/gpu/drm/omapdrm/dss/sdi.c  |  5 -
 drivers/gpu/drm/omapdrm/dss/venc.c |  5 -
 12 files changed, 25 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index 5b9ef09e6b2d..6baca0dc2b62 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -51,9 +51,6 @@ static int opa362_connect(struct omap_dss_device *dssdev,
return r;
}
 
-   dst->src = dssdev;
-   dssdev->dst = dst;
-
ddata->in = in;
return 0;
 }
@@ -64,13 +61,6 @@ static void opa362_disconnect(struct omap_dss_device *dssdev,
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
 
-   WARN_ON(dst != dssdev->dst);
-   if (dst != dssdev->dst)
-   return;
-
-   dst->src = NULL;
-   dssdev->dst = NULL;
-
omapdss_device_disconnect(in, >dssdev);
 
omap_dss_put_device(in);
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index b22c8f71c0e5..c1ae8bebf04d 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -47,9 +47,6 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
return r;
}
 
-   dst->src = dssdev;
-   dssdev->dst = dst;
-
ddata->in = in;
return 0;
 }
@@ -60,13 +57,6 @@ static void tfp410_disconnect(struct omap_dss_device *dssdev,
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
 
-   WARN_ON(dst != dssdev->dst);
-   if (dst != dssdev->dst)
-   return;
-
-   dst->src = NULL;
-   dssdev->dst = NULL;
-
omapdss_device_disconnect(in, >dssdev);
 
omap_dss_put_device(in);
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
index 00fa360163a3..71a8269b797a 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
@@ -55,9 +55,6 @@ static int tpd_connect(struct omap_dss_device *dssdev,
return r;
}
 
-   dst->src = dssdev;
-   dssdev->dst = dst;
-
gpiod_set_value_cansleep(ddata->ct_cp_hpd_gpio, 1);
gpiod_set_value_cansleep(ddata->ls_oe_gpio, 1);
 
@@ -74,17 +71,9 @@ static void tpd_disconnect(struct omap_dss_device *dssdev,
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
 
-   WARN_ON(dst != dssdev->dst);
-
-   if (dst != dssdev->dst)
-   return;
-
gpiod_set_value_cansleep(ddata->ct_cp_hpd_gpio, 0);
gpiod_set_value_cansleep(ddata->ls_oe_gpio, 0);
 
-   dst->src = NULL;
-   dssdev->dst = NULL;
-
omapdss_device_disconnect(in, >dssdev);
 
omap_dss_put_device(in);
diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 01c117d8775b..810dcddded8a 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -105,15 +105,27 @@ struct omap_dss_device 
*omapdss_find_device_by_port(struct device_node *src,
 int omapdss_device_connect(struct omap_dss_device *src,
   struct omap_dss_device *dst)
 {
+   int ret;
+
dev_dbg(src->dev, "connect\n");
 
if (omapdss_device_is_connected(src))
return -EBUSY;
 
if (src->driver)
-   return src->driver->connect(src);
+   ret = src->driver->connect(src);
else
-   return src->ops->connect(src, dst);
+   ret = src->ops->connect(src, dst);
+
+   if (ret < 0)
+   return ret;
+
+   if (dst) {
+   dst->src = src;
+   src->dst = dst;
+   }
+
+   return 0;
 }
 

[PATCH/RFC 37/60] drm/omap: displays: Don't cast dssdev to panel data unnecessarily

2018-03-06 Thread Laurent Pinchart
The connect handle of the analog TV and HDMI connectors casts the dssdev
to panel data only to then access fields of the panel data that are also
present in the dssdev. Remove the cast and use dssdev directly.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c | 5 ++---
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c  | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index 4f32c8ddcfbd..eab898b5bf0f 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -43,13 +43,12 @@ static const struct videomode tvc_pal_vm = {
 
 static int tvc_connect(struct omap_dss_device *dssdev)
 {
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *src;
int r;
 
-   src = omapdss_of_find_connected_device(ddata->dev->of_node, 0);
+   src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
if (IS_ERR_OR_NULL(src)) {
-   dev_err(ddata->dev, "failed to find video source\n");
+   dev_err(dssdev->dev, "failed to find video source\n");
return src ? PTR_ERR(src) : -EINVAL;
}
 
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 1df7ffd8b97d..360bc9f501a2 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -53,13 +53,12 @@ struct panel_drv_data {
 
 static int hdmic_connect(struct omap_dss_device *dssdev)
 {
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *src;
int r;
 
-   src = omapdss_of_find_connected_device(ddata->dev->of_node, 0);
+   src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
if (IS_ERR_OR_NULL(src)) {
-   dev_err(ddata->dev, "failed to find video source\n");
+   dev_err(dssdev->dev, "failed to find video source\n");
return src ? PTR_ERR(src) : -EINVAL;
}
 
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 32/60] drm/omap: dss: Store dss_device pointer in omap_dss_device

2018-03-06 Thread Laurent Pinchart
Storing the dss_device pointer in the omap_dss_device structure will
allow accessing the dss_device from the dss_mgr API functions.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c  |  2 +-
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c|  2 +-
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c   |  2 +-
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c   |  2 +-
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c   |  2 +-
 drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c|  2 +-
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c|  2 +-
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c |  2 +-
 drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c |  2 +-
 drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c |  2 +-
 drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c  |  2 +-
 drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c |  2 +-
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c |  2 +-
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c |  2 +-
 drivers/gpu/drm/omapdrm/dss/base.c  | 11 +--
 drivers/gpu/drm/omapdrm/dss/omapdss.h   |  4 +++-
 drivers/gpu/drm/omapdrm/omap_drv.c  |  2 +-
 17 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index a7eb25bd9283..f7250db0f3b7 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -53,7 +53,7 @@ static int tvc_connect(struct omap_dss_device *dssdev)
return PTR_ERR(src);
}
 
-   r = omapdss_device_connect(src, dssdev);
+   r = omapdss_device_connect(dssdev->dss, src, dssdev);
if (r) {
omapdss_device_put(src);
return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 3e71af9ba0c3..b4f84baff144 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -67,7 +67,7 @@ static int dvic_connect(struct omap_dss_device *dssdev)
return PTR_ERR(src);
}
 
-   r = omapdss_device_connect(src, dssdev);
+   r = omapdss_device_connect(dssdev->dss, src, dssdev);
if (r) {
omapdss_device_put(src);
return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 4fbc1ba84bee..0ec048b51fb5 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -63,7 +63,7 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
return PTR_ERR(src);
}
 
-   r = omapdss_device_connect(src, dssdev);
+   r = omapdss_device_connect(dssdev->dss, src, dssdev);
if (r) {
omapdss_device_put(src);
return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index 01b00eea3a98..4d7f4dae2c10 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -43,7 +43,7 @@ static int opa362_connect(struct omap_dss_device *dssdev,
return PTR_ERR(src);
}
 
-   r = omapdss_device_connect(src, dssdev);
+   r = omapdss_device_connect(dssdev->dss, src, dssdev);
if (r) {
omapdss_device_put(src);
return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index 6f71d2b7de03..833544d8502f 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -39,7 +39,7 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
return PTR_ERR(src);
}
 
-   r = omapdss_device_connect(src, dssdev);
+   r = omapdss_device_connect(dssdev->dss, src, dssdev);
if (r) {
omapdss_device_put(src);
return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
index 0004a3ba2aa3..bc4f7d670aac 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
@@ -48,7 +48,7 @@ static int tpd_connect(struct omap_dss_device *dssdev,
return PTR_ERR(src);
}
 
-   r = omapdss_device_connect(src, dssdev);
+   r = omapdss_device_connect(dssdev->dss, src, dssdev);
if (r) {
omapdss_device_put(src);
return r;
diff 

[PATCH/RFC 30/60] drm/omap: dss: Remove panel devices list

2018-03-06 Thread Laurent Pinchart
The panel devices list isn't used anymore, all panel devices are
accessed through the global devices list. Remove it.

Signed-off-by: Laurent Pinchart 
---
 .../gpu/drm/omapdrm/displays/connector-analog-tv.c |  9 ++--
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c   | 14 ++-
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c  |  8 ++-
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c   |  8 ++-
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c|  8 ++-
 .../omapdrm/displays/panel-lgphilips-lb035q02.c|  8 ++-
 .../drm/omapdrm/displays/panel-nec-nl8048hl11.c|  8 ++-
 .../drm/omapdrm/displays/panel-sharp-ls037v7dw01.c |  8 ++-
 .../drm/omapdrm/displays/panel-sony-acx565akm.c| 27 +++---
 .../drm/omapdrm/displays/panel-tpo-td028ttec1.c|  8 ++-
 .../drm/omapdrm/displays/panel-tpo-td043mtea1.c| 22 --
 drivers/gpu/drm/omapdrm/dss/display.c  | 23 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  3 ---
 13 files changed, 31 insertions(+), 123 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index fb23fae7fbf4..f1d1c67d72b8 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -154,7 +154,6 @@ static int tvc_probe(struct platform_device *pdev)
 {
struct panel_drv_data *ddata;
struct omap_dss_device *dssdev;
-   int r;
 
ddata = devm_kzalloc(>dev, sizeof(*ddata), GFP_KERNEL);
if (!ddata)
@@ -172,11 +171,7 @@ static int tvc_probe(struct platform_device *pdev)
dssdev->owner = THIS_MODULE;
 
omapdss_display_init(dssdev);
-   r = omapdss_register_display(dssdev);
-   if (r) {
-   dev_err(>dev, "Failed to register panel\n");
-   return r;
-   }
+   omapdss_device_register(dssdev);
 
return 0;
 }
@@ -186,7 +181,7 @@ static int __exit tvc_remove(struct platform_device *pdev)
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *dssdev = >dssdev;
 
-   omapdss_unregister_display(>dssdev);
+   omapdss_device_unregister(>dssdev);
 
tvc_disable(dssdev);
tvc_disconnect(dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 5333fb166c83..9e0b5a0b2eea 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -391,19 +391,9 @@ static int dvic_probe(struct platform_device *pdev)
dssdev->owner = THIS_MODULE;
 
omapdss_display_init(dssdev);
-   r = omapdss_register_display(dssdev);
-   if (r) {
-   dev_err(>dev, "Failed to register panel\n");
-   goto err_reg;
-   }
+   omapdss_device_register(dssdev);
 
return 0;
-
-err_reg:
-   i2c_put_adapter(ddata->i2c_adapter);
-   mutex_destroy(>hpd_lock);
-
-   return r;
 }
 
 static int __exit dvic_remove(struct platform_device *pdev)
@@ -411,7 +401,7 @@ static int __exit dvic_remove(struct platform_device *pdev)
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *dssdev = >dssdev;
 
-   omapdss_unregister_display(>dssdev);
+   omapdss_device_unregister(>dssdev);
 
dvic_disable(dssdev);
dvic_disconnect(dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 22b3efa06dc7..882883f811fb 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -342,11 +342,7 @@ static int hdmic_probe(struct platform_device *pdev)
dssdev->owner = THIS_MODULE;
 
omapdss_display_init(dssdev);
-   r = omapdss_register_display(dssdev);
-   if (r) {
-   dev_err(>dev, "Failed to register panel\n");
-   return r;
-   }
+   omapdss_device_register(dssdev);
 
return 0;
 }
@@ -356,7 +352,7 @@ static int __exit hdmic_remove(struct platform_device *pdev)
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *dssdev = >dssdev;
 
-   omapdss_unregister_display(>dssdev);
+   omapdss_device_unregister(>dssdev);
 
hdmic_disable(dssdev);
hdmic_disconnect(dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
index 87f11618e85f..bd598be1ba6b 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
@@ -219,11 +219,7 @@ static int panel_dpi_probe(struct platform_device *pdev)
dssdev->owner = THIS_MODULE;
 
omapdss_display_init(dssdev);
-   r = 

[PATCH/RFC 39/60] drm/omap: dss: dsi: Move initialization code from bind to probe

2018-03-06 Thread Laurent Pinchart
There's no reason to delay initialization of most of the driver (such as
mapping memory I/O or enabling runtime PM) to the component bind
handler. Perform as much of the initialization as possible at probe
time, initializing at bind time only the parts that depends on the DSS.
The cleanup code is moved from unbind to remove in a similar way.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 301 --
 1 file changed, 161 insertions(+), 140 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 278094f29255..79312e53bfd9 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4981,85 +4981,9 @@ static const struct omap_dss_device_ops dsi_ops = {
},
 };
 
-static void dsi_init_output(struct dsi_data *dsi)
-{
-   struct omap_dss_device *out = >output;
-
-   out->dev = dsi->dev;
-   out->id = dsi->module_id == 0 ?
-   OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2;
-
-   out->output_type = OMAP_DISPLAY_TYPE_DSI;
-   out->name = dsi->module_id == 0 ? "dsi.0" : "dsi.1";
-   out->dispc_channel = dsi_get_channel(dsi);
-   out->ops = _ops;
-   out->owner = THIS_MODULE;
-   out->of_ports = BIT(0);
-
-   omapdss_device_register(out);
-}
-
-static void dsi_uninit_output(struct dsi_data *dsi)
-{
-   struct omap_dss_device *out = >output;
-
-   omapdss_device_unregister(out);
-}
-
-static int dsi_probe_of(struct dsi_data *dsi)
-{
-   struct device_node *node = dsi->dev->of_node;
-   struct property *prop;
-   u32 lane_arr[10];
-   int len, num_pins;
-   int r, i;
-   struct device_node *ep;
-   struct omap_dsi_pin_config pin_cfg;
-
-   ep = of_graph_get_endpoint_by_regs(node, 0, 0);
-   if (!ep)
-   return 0;
-
-   prop = of_find_property(ep, "lanes", );
-   if (prop == NULL) {
-   dev_err(dsi->dev, "failed to find lane data\n");
-   r = -EINVAL;
-   goto err;
-   }
-
-   num_pins = len / sizeof(u32);
-
-   if (num_pins < 4 || num_pins % 2 != 0 ||
-   num_pins > dsi->num_lanes_supported * 2) {
-   dev_err(dsi->dev, "bad number of lanes\n");
-   r = -EINVAL;
-   goto err;
-   }
-
-   r = of_property_read_u32_array(ep, "lanes", lane_arr, num_pins);
-   if (r) {
-   dev_err(dsi->dev, "failed to read lane data\n");
-   goto err;
-   }
-
-   pin_cfg.num_pins = num_pins;
-   for (i = 0; i < num_pins; ++i)
-   pin_cfg.pins[i] = (int)lane_arr[i];
-
-   r = dsi_configure_pins(>output, _cfg);
-   if (r) {
-   dev_err(dsi->dev, "failed to configure pins");
-   goto err;
-   }
-
-   of_node_put(ep);
-
-   return 0;
-
-err:
-   of_node_put(ep);
-   return r;
-}
+/* 
-
+ * PLL
+ */
 
 static const struct dss_pll_ops dsi_pll_ops = {
.enable = dsi_pll_enable,
@@ -5174,7 +5098,153 @@ static int dsi_init_pll_data(struct dss_device *dss, 
struct dsi_data *dsi)
return 0;
 }
 
-/* DSI1 HW IP initialisation */
+/* 
-
+ * Component Bind & Unbind
+ */
+
+static int dsi_bind(struct device *dev, struct device *master, void *data)
+{
+   struct dss_device *dss = dss_get_device(master);
+   struct dsi_data *dsi = dev_get_drvdata(dev);
+   char name[10];
+   u32 rev;
+   int r;
+
+   dsi->dss = dss;
+
+   dsi_init_pll_data(dss, dsi);
+
+   r = dsi_runtime_get(dsi);
+   if (r)
+   return r;
+
+   rev = dsi_read_reg(dsi, DSI_REVISION);
+   dev_dbg(dev, "OMAP DSI rev %d.%d\n",
+  FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
+
+   dsi->line_buffer_size = dsi_get_line_buf_size(dsi);
+
+   dsi_runtime_put(dsi);
+
+   snprintf(name, sizeof(name), "dsi%u_regs", dsi->module_id + 1);
+   dsi->debugfs.regs = dss_debugfs_create_file(dss, name,
+   dsi_dump_dsi_regs, );
+#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
+   snprintf(name, sizeof(name), "dsi%u_irqs", dsi->module_id + 1);
+   dsi->debugfs.irqs = dss_debugfs_create_file(dss, name,
+   dsi_dump_dsi_irqs, );
+#endif
+   snprintf(name, sizeof(name), "dsi%u_clks", dsi->module_id + 1);
+   dsi->debugfs.clks = dss_debugfs_create_file(dss, name,
+   dsi_dump_dsi_clocks, );
+
+   return 0;
+}
+
+static void dsi_unbind(struct device *dev, struct device *master, void *data)
+{
+   struct dsi_data *dsi = dev_get_drvdata(dev);
+
+   dss_debugfs_remove_file(dsi->debugfs.clks);
+   

[PATCH/RFC 19/60] drm/omap: dss: Move common device operations to common structure

2018-03-06 Thread Laurent Pinchart
The various types of omapdss_*_ops structures define multiple operations
that are not specific to a bus type. To simplify the code and remove
dependencies on specific bus types move those operations to a common
structure. Operations that are specific to a bus type are kept in the
specialized ops structures.

Signed-off-by: Laurent Pinchart 
---
 .../gpu/drm/omapdrm/displays/connector-analog-tv.c |  14 +--
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c   |  14 +--
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c  |  40 +++
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c  |  20 ++--
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c  |  20 ++--
 .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c   |  44 
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c   |  16 +--
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c| 120 ++---
 .../omapdrm/displays/panel-lgphilips-lb035q02.c|  14 +--
 .../drm/omapdrm/displays/panel-nec-nl8048hl11.c|  14 +--
 .../drm/omapdrm/displays/panel-sharp-ls037v7dw01.c |  14 +--
 .../drm/omapdrm/displays/panel-sony-acx565akm.c|  14 +--
 .../drm/omapdrm/displays/panel-tpo-td028ttec1.c|  14 +--
 .../drm/omapdrm/displays/panel-tpo-td043mtea1.c|  16 +--
 drivers/gpu/drm/omapdrm/dss/dpi.c  |   4 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c  |  50 -
 drivers/gpu/drm/omapdrm/dss/hdmi4.c|  12 ++-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c|  10 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h  | 109 ---
 drivers/gpu/drm/omapdrm/dss/sdi.c  |   4 +-
 drivers/gpu/drm/omapdrm/dss/venc.c |   4 +-
 21 files changed, 251 insertions(+), 316 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index 6b640ede6614..a94868d9398b 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -59,7 +59,7 @@ static int tvc_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in);
}
 
-   r = in->ops.atv->connect(in, dssdev);
+   r = in->ops->connect(in, dssdev);
if (r) {
omap_dss_put_device(in);
return r;
@@ -79,7 +79,7 @@ static void tvc_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev))
return;
 
-   in->ops.atv->disconnect(in, dssdev);
+   in->ops->disconnect(in, dssdev);
 
omap_dss_put_device(in);
ddata->in = NULL;
@@ -99,9 +99,9 @@ static int tvc_enable(struct omap_dss_device *dssdev)
if (omapdss_device_is_enabled(dssdev))
return 0;
 
-   in->ops.atv->set_timings(in, >vm);
+   in->ops->set_timings(in, >vm);
 
-   r = in->ops.atv->enable(in);
+   r = in->ops->enable(in);
if (r)
return r;
 
@@ -120,7 +120,7 @@ static void tvc_disable(struct omap_dss_device *dssdev)
if (!omapdss_device_is_enabled(dssdev))
return;
 
-   in->ops.atv->disable(in);
+   in->ops->disable(in);
 
dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
 }
@@ -133,7 +133,7 @@ static void tvc_set_timings(struct omap_dss_device *dssdev,
 
ddata->vm = *vm;
 
-   in->ops.atv->set_timings(in, vm);
+   in->ops->set_timings(in, vm);
 }
 
 static void tvc_get_timings(struct omap_dss_device *dssdev,
@@ -150,7 +150,7 @@ static int tvc_check_timings(struct omap_dss_device *dssdev,
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
 
-   return in->ops.atv->check_timings(in, vm);
+   return in->ops->check_timings(in, vm);
 }
 
 static const struct omap_dss_driver tvc_driver = {
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 84598ea12a9b..021e3b651c89 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -72,7 +72,7 @@ static int dvic_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in);
}
 
-   r = in->ops.dvi->connect(in, dssdev);
+   r = in->ops->connect(in, dssdev);
if (r) {
omap_dss_put_device(in);
return r;
@@ -90,7 +90,7 @@ static void dvic_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev))
return;
 
-   in->ops.dvi->disconnect(in, dssdev);
+   in->ops->disconnect(in, dssdev);
 
omap_dss_put_device(in);
ddata->in = NULL;
@@ -108,9 +108,9 @@ static int dvic_enable(struct omap_dss_device *dssdev)
if (omapdss_device_is_enabled(dssdev))
return 0;
 
-   in->ops.dvi->set_timings(in, >vm);
+   in->ops->set_timings(in, >vm);
 
-   r = 

[PATCH/RFC 28/60] drm/omap: dss: Make omap_dss_get_next_device() more generic

2018-03-06 Thread Laurent Pinchart
Despite its name, the omap_dss_get_next_device() function operates on
display devices only. Make it more generic by allowing operation on all
devices, with a parameter to specify the device type.

While at it rename the function to omapdss_device_get_next() to match
the naming of the other functions operating on struct omap_dss_device.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/base.c| 52 +++
 drivers/gpu/drm/omapdrm/dss/display.c | 49 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  6 ++--
 3 files changed, 56 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 7cd3076c2140..f7b8958f15bc 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -104,6 +104,58 @@ struct omap_dss_device *omapdss_find_device_by_port(struct 
device_node *src,
return NULL;
 }
 
+/*
+ * Search for the next device starting at @from. If display_only is true, skip
+ * non-display devices. Release the reference to the @from device, and acquire
+ * a reference to the returned device if found.
+ */
+struct omap_dss_device *omapdss_device_get_next(struct omap_dss_device *from,
+   bool display_only)
+{
+   struct omap_dss_device *dssdev;
+   struct list_head *list;
+
+   mutex_lock(_devices_lock);
+
+   if (list_empty(_devices_list)) {
+   dssdev = NULL;
+   goto done;
+   }
+
+   /*
+* Start from the from entry if given or from omapdss_devices_list
+* otherwise.
+*/
+   list = from ? >list : _devices_list;
+
+   list_for_each_entry(dssdev, list, list) {
+   /*
+* Stop if we reach the omapdss_devices_list, that's the end of
+* the list.
+*/
+   if (>list == _devices_list) {
+   dssdev = NULL;
+   goto done;
+   }
+
+   /* Filter out non-display entries if display_only is set. */
+   if (!display_only || dssdev->driver)
+   goto done;
+   }
+
+   dssdev = NULL;
+
+done:
+   if (from)
+   omap_dss_put_device(from);
+   if (dssdev)
+   omap_dss_get_device(dssdev);
+
+   mutex_unlock(_devices_lock);
+   return dssdev;
+}
+EXPORT_SYMBOL(omapdss_device_get_next);
+
 int omapdss_device_connect(struct omap_dss_device *src,
   struct omap_dss_device *dst)
 {
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c 
b/drivers/gpu/drm/omapdrm/dss/display.c
index 383512c8a466..0c94d5208398 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -92,52 +92,3 @@ void omap_dss_put_device(struct omap_dss_device *dssdev)
module_put(dssdev->owner);
 }
 EXPORT_SYMBOL(omap_dss_put_device);
-
-/*
- * ref count of the found device is incremented.
- * ref count of from-device is decremented.
- */
-struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from)
-{
-   struct list_head *l;
-   struct omap_dss_device *dssdev;
-
-   mutex_lock(_list_mutex);
-
-   if (list_empty(_list)) {
-   dssdev = NULL;
-   goto out;
-   }
-
-   if (from == NULL) {
-   dssdev = list_first_entry(_list, struct omap_dss_device,
-   panel_list);
-   omap_dss_get_device(dssdev);
-   goto out;
-   }
-
-   omap_dss_put_device(from);
-
-   list_for_each(l, _list) {
-   dssdev = list_entry(l, struct omap_dss_device, panel_list);
-   if (dssdev == from) {
-   if (list_is_last(l, _list)) {
-   dssdev = NULL;
-   goto out;
-   }
-
-   dssdev = list_entry(l->next, struct omap_dss_device,
-   panel_list);
-   omap_dss_get_device(dssdev);
-   goto out;
-   }
-   }
-
-   WARN(1, "'from' dssdev not found\n");
-
-   dssdev = NULL;
-out:
-   mutex_unlock(_list_mutex);
-   return dssdev;
-}
-EXPORT_SYMBOL(omap_dss_get_next_device);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index a2d146ed3924..af68d10fe7ef 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -487,11 +487,15 @@ static inline bool omapdss_is_initialized(void)
 
 int omapdss_register_display(struct omap_dss_device *dssdev);
 void omapdss_unregister_display(struct omap_dss_device *dssdev);
+#define for_each_dss_display(d) \
+   while ((d = omapdss_device_get_next(d, true)) != NULL)
 
 void omapdss_device_register(struct 

[PATCH/RFC 14/60] drm/omap: dss: Rename omap_dss_device list field to output_list

2018-03-06 Thread Laurent Pinchart
For coherency with the panel_list field, rename list to output_list.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  2 +-
 drivers/gpu/drm/omapdrm/dss/output.c  | 10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 8e81652b82d5..9f6c0385b7de 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -479,7 +479,7 @@ struct omap_dss_device {
 
/* OMAP DSS output specific fields */
 
-   struct list_head list;
+   struct list_head output_list;
 
/* DISPC channel for this output */
enum omap_channel dispc_channel;
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index 96b9d4cd505f..0fcd13ea8824 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -96,14 +96,14 @@ EXPORT_SYMBOL(omapdss_output_unset_device);
 
 int omapdss_register_output(struct omap_dss_device *out)
 {
-   list_add_tail(>list, _list);
+   list_add_tail(>output_list, _list);
return 0;
 }
 EXPORT_SYMBOL(omapdss_register_output);
 
 void omapdss_unregister_output(struct omap_dss_device *out)
 {
-   list_del(>list);
+   list_del(>output_list);
 }
 EXPORT_SYMBOL(omapdss_unregister_output);
 
@@ -111,7 +111,7 @@ bool omapdss_component_is_output(struct device_node *node)
 {
struct omap_dss_device *out;
 
-   list_for_each_entry(out, _list, list) {
+   list_for_each_entry(out, _list, output_list) {
if (out->dev->of_node == node)
return true;
}
@@ -124,7 +124,7 @@ struct omap_dss_device *omap_dss_get_output(enum 
omap_dss_output_id id)
 {
struct omap_dss_device *out;
 
-   list_for_each_entry(out, _list, list) {
+   list_for_each_entry(out, _list, output_list) {
if (out->id == id)
return out;
}
@@ -145,7 +145,7 @@ struct omap_dss_device 
*omap_dss_find_output_by_port_node(struct device_node *po
 
reg = dss_of_port_get_port_number(port);
 
-   list_for_each_entry(out, _list, list) {
+   list_for_each_entry(out, _list, output_list) {
if (out->dev->of_node == src_node && out->port_num == reg) {
of_node_put(src_node);
return omap_dss_get_device(out);
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 21/60] drm/omap: dss: Move debug message and checks to connection handlers

2018-03-06 Thread Laurent Pinchart
The connectors, encoders and display duplicate the same debug messages
and connection checks in their omap_dss_device connect and disconnect
handlers. Move the code to the connect and disconnect wrappers.

To simplify the code the connect function returns -EBUSY unconditionally
if the device is already connected. This doesn't cause any change in
practice: the connect handler of displays is never called on a connected
device as it is only invoked during omapdrm initialization.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c  | 10 --
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c|  6 --
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c   | 10 --
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c   | 11 ---
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c   |  7 ---
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c|  6 --
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c |  6 --
 drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c |  6 --
 drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c |  6 --
 drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c  |  6 --
 drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c |  6 --
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c |  6 --
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c |  6 --
 drivers/gpu/drm/omapdrm/dss/base.c  | 12 
 14 files changed, 12 insertions(+), 92 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index 41ba3c5dbe7d..d77e21fc26ad 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -48,11 +48,6 @@ static int tvc_connect(struct omap_dss_device *dssdev)
struct omap_dss_device *in;
int r;
 
-   dev_dbg(ddata->dev, "connect\n");
-
-   if (omapdss_device_is_connected(dssdev))
-   return 0;
-
in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
if (IS_ERR(in)) {
dev_err(ddata->dev, "failed to find video source\n");
@@ -74,11 +69,6 @@ static void tvc_disconnect(struct omap_dss_device *dssdev)
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
 
-   dev_dbg(ddata->dev, "disconnect\n");
-
-   if (!omapdss_device_is_connected(dssdev))
-   return;
-
omapdss_device_disconnect(in, dssdev);
 
omap_dss_put_device(in);
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index f193bbda550c..9a3ecc3ed5b2 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -63,9 +63,6 @@ static int dvic_connect(struct omap_dss_device *dssdev)
struct omap_dss_device *in;
int r;
 
-   if (omapdss_device_is_connected(dssdev))
-   return 0;
-
in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
if (IS_ERR(in)) {
dev_err(dssdev->dev, "failed to find video source\n");
@@ -87,9 +84,6 @@ static void dvic_disconnect(struct omap_dss_device *dssdev)
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
 
-   if (!omapdss_device_is_connected(dssdev))
-   return;
-
omapdss_device_disconnect(in, dssdev);
 
omap_dss_put_device(in);
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 480fbd6fac1e..ed7fa2295f84 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -58,11 +58,6 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
struct omap_dss_device *in;
int r;
 
-   dev_dbg(ddata->dev, "connect\n");
-
-   if (omapdss_device_is_connected(dssdev))
-   return 0;
-
in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
if (IS_ERR(in)) {
dev_err(ddata->dev, "failed to find video source\n");
@@ -84,11 +79,6 @@ static void hdmic_disconnect(struct omap_dss_device *dssdev)
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
 
-   dev_dbg(ddata->dev, "disconnect\n");
-
-   if (!omapdss_device_is_connected(dssdev))
-   return;
-
omapdss_device_disconnect(in, dssdev);
 
omap_dss_put_device(in);
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index 752b565987c1..5b9ef09e6b2d 100644
--- 

[PATCH/RFC 27/60] drm/omap: dss: Rename for_each_dss_dev macro to for_each_dss_display

2018-03-06 Thread Laurent Pinchart
The macro iterates over displays only, rename it accordingly.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 2 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c| 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index acafc6077a80..79bc43135808 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1552,7 +1552,7 @@ static void dss_shutdown(struct platform_device *pdev)
 
DSSDBG("shutdown\n");
 
-   for_each_dss_dev(dssdev) {
+   for_each_dss_display(dssdev) {
if (!dssdev->driver)
continue;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 8d2258aec952..a2d146ed3924 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -499,7 +499,7 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
 
 struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
 void omap_dss_put_device(struct omap_dss_device *dssdev);
-#define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
+#define for_each_dss_display(d) while ((d = omap_dss_get_next_device(d)) != 
NULL)
 struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
 
 int omap_dss_get_num_overlay_managers(void);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 3e7d3fc79f49..ccab3865683c 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -188,7 +188,7 @@ static int omap_connect_dssdevs(struct drm_device *ddev)
if (!omapdss_stack_is_ready())
return -EPROBE_DEFER;
 
-   for_each_dss_dev(dssdev) {
+   for_each_dss_display(dssdev) {
r = omapdss_device_connect(dssdev, NULL);
if (r == -EPROBE_DEFER) {
omap_dss_put_device(dssdev);
@@ -200,7 +200,7 @@ static int omap_connect_dssdevs(struct drm_device *ddev)
omap_dss_get_device(dssdev);
priv->dssdevs[priv->num_dssdevs++] = dssdev;
if (priv->num_dssdevs == ARRAY_SIZE(priv->dssdevs)) {
-   /* To balance the 'for_each_dss_dev' loop */
+   /* To balance the 'for_each_dss_display' loop */
omap_dss_put_device(dssdev);
break;
}
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 24/60] drm/omap: dsi: Simplify debugfs implementation

2018-03-06 Thread Laurent Pinchart
The DSI debugfs regs and irqs show handlers received a pointer to the
DSI private data. There's no need to look it up from the list of DSS
outputs. Use the pointer directly, this allows simplifying the
implementation of the handlers.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 63 +--
 1 file changed, 14 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 4427389e0049..9952803b58d2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -1518,8 +1518,9 @@ void dsi_dump_clocks(struct seq_file *s)
 }
 
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
-static void dsi_dump_dsi_irqs(struct dsi_data *dsi, struct seq_file *s)
+static int dsi_dump_dsi_irqs(struct seq_file *s, void *p)
 {
+   struct dsi_data *dsi = p;
unsigned long flags;
struct dsi_irq_stats stats;
 
@@ -1603,33 +1604,20 @@ static void dsi_dump_dsi_irqs(struct dsi_data *dsi, 
struct seq_file *s)
PIS(ULPSACTIVENOT_ALL0);
PIS(ULPSACTIVENOT_ALL1);
 #undef PIS
-}
-
-static int dsi1_dump_irqs(struct seq_file *s, void *p)
-{
-   struct dsi_data *dsi = dsi_get_dsi_from_id(0);
 
-   dsi_dump_dsi_irqs(dsi, s);
-   return 0;
-}
-
-static int dsi2_dump_irqs(struct seq_file *s, void *p)
-{
-   struct dsi_data *dsi = dsi_get_dsi_from_id(1);
-
-   dsi_dump_dsi_irqs(dsi, s);
return 0;
 }
 #endif
 
-static void dsi_dump_dsi_regs(struct dsi_data *dsi, struct seq_file *s)
+static int dsi_dump_dsi_regs(struct seq_file *s, void *p)
 {
-#define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dsi_read_reg(dsi, r))
+   struct dsi_data *dsi = p;
 
if (dsi_runtime_get(dsi))
-   return;
+   return 0;
dsi_enable_scp_clk(dsi);
 
+#define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dsi_read_reg(dsi, r))
DUMPREG(DSI_REVISION);
DUMPREG(DSI_SYSCONFIG);
DUMPREG(DSI_SYSSTATUS);
@@ -1699,25 +1687,11 @@ static void dsi_dump_dsi_regs(struct dsi_data *dsi, 
struct seq_file *s)
DUMPREG(DSI_PLL_GO);
DUMPREG(DSI_PLL_CONFIGURATION1);
DUMPREG(DSI_PLL_CONFIGURATION2);
+#undef DUMPREG
 
dsi_disable_scp_clk(dsi);
dsi_runtime_put(dsi);
-#undef DUMPREG
-}
-
-static int dsi1_dump_regs(struct seq_file *s, void *p)
-{
-   struct dsi_data *dsi = dsi_get_dsi_from_id(0);
 
-   dsi_dump_dsi_regs(dsi, s);
-   return 0;
-}
-
-static int dsi2_dump_regs(struct seq_file *s, void *p)
-{
-   struct dsi_data *dsi = dsi_get_dsi_from_id(1);
-
-   dsi_dump_dsi_regs(dsi, s);
return 0;
 }
 
@@ -5305,6 +5279,7 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
struct dsi_data *dsi;
struct resource *dsi_mem;
struct resource *res;
+   char name[10];
 
dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
if (!dsi)
@@ -5443,23 +5418,13 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
 
dsi_runtime_put(dsi);
 
-   if (dsi->module_id == 0)
-   dsi->debugfs.regs = dss_debugfs_create_file(dss, "dsi1_regs",
-   dsi1_dump_regs,
-   );
-   else
-   dsi->debugfs.regs = dss_debugfs_create_file(dss, "dsi2_regs",
-   dsi2_dump_regs,
-   );
+   snprintf(name, sizeof(name), "dsi%u_regs", dsi->module_id + 1);
+   dsi->debugfs.regs = dss_debugfs_create_file(dss, name,
+   dsi_dump_dsi_regs, );
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
-   if (dsi->module_id == 0)
-   dsi->debugfs.irqs = dss_debugfs_create_file(dss, "dsi1_irqs",
-   dsi1_dump_irqs,
-   );
-   else
-   dsi->debugfs.irqs = dss_debugfs_create_file(dss, "dsi2_irqs",
-   dsi2_dump_irqs,
-   );
+   snprintf(name, sizeof(name), "dsi%u_irqs", dsi->module_id + 1);
+   dsi->debugfs.irqs = dss_debugfs_create_file(dss, name,
+   dsi_dump_dsi_irqs, );
 #endif
 
return 0;
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 29/60] drm/omap: dss: Split omapdss_register_display()

2018-03-06 Thread Laurent Pinchart
Split the function into omapdss_display_init() to perform
display-specific initialization of the omap_dss_device, and
omapdss_register_display() to register the device. The latter will then
be replaced by more generic registration.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c  | 1 +
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c| 1 +
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c   | 1 +
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c| 1 +
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 1 +
 drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c | 1 +
 drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c | 1 +
 drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c  | 1 +
 drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c | 1 +
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c | 1 +
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c | 1 +
 drivers/gpu/drm/omapdrm/dss/display.c   | 6 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h   | 1 +
 13 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index f579bd9ce7cb..fb23fae7fbf4 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -171,6 +171,7 @@ static int tvc_probe(struct platform_device *pdev)
dssdev->type = OMAP_DISPLAY_TYPE_VENC;
dssdev->owner = THIS_MODULE;
 
+   omapdss_display_init(dssdev);
r = omapdss_register_display(dssdev);
if (r) {
dev_err(>dev, "Failed to register panel\n");
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 48dbb9df76b5..5333fb166c83 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -390,6 +390,7 @@ static int dvic_probe(struct platform_device *pdev)
dssdev->type = OMAP_DISPLAY_TYPE_DVI;
dssdev->owner = THIS_MODULE;
 
+   omapdss_display_init(dssdev);
r = omapdss_register_display(dssdev);
if (r) {
dev_err(>dev, "Failed to register panel\n");
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 807dfbf08a5e..22b3efa06dc7 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -341,6 +341,7 @@ static int hdmic_probe(struct platform_device *pdev)
dssdev->type = OMAP_DISPLAY_TYPE_HDMI;
dssdev->owner = THIS_MODULE;
 
+   omapdss_display_init(dssdev);
r = omapdss_register_display(dssdev);
if (r) {
dev_err(>dev, "Failed to register panel\n");
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
index 32af5b11b448..87f11618e85f 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
@@ -218,6 +218,7 @@ static int panel_dpi_probe(struct platform_device *pdev)
dssdev->type = OMAP_DISPLAY_TYPE_DPI;
dssdev->owner = THIS_MODULE;
 
+   omapdss_display_init(dssdev);
r = omapdss_register_display(dssdev);
if (r) {
dev_err(>dev, "Failed to register panel\n");
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 353510af58e7..94275fc931be 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -1328,6 +1328,7 @@ static int dsicm_probe(struct platform_device *pdev)
dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE |
OMAP_DSS_DISPLAY_CAP_TEAR_ELIM;
 
+   omapdss_display_init(dssdev);
r = omapdss_register_display(dssdev);
if (r) {
dev_err(dev, "Failed to register panel\n");
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c 
b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
index 5bea3eadd7d2..88c075414b7c 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
@@ -270,6 +270,7 @@ static int lb035q02_panel_spi_probe(struct spi_device *spi)
dssdev->type = OMAP_DISPLAY_TYPE_DPI;
dssdev->owner = THIS_MODULE;
 
+   omapdss_display_init(dssdev);
r = omapdss_register_display(dssdev);
if (r) {
dev_err(>dev, "Failed to register panel\n");
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c 
b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
index d03339034f18..fafb3e43f390 100644
--- 

[PATCH/RFC 18/60] drm/omap: dss: Allow looking up any device by port

2018-03-06 Thread Laurent Pinchart
The omap_dss_find_output_by_port() function looks up an omap_dss_device
by port from the list of devices registered as outputs. In preparation
for looking up sinks in addition to sources, allow the function to look
up any registered device. Rename it to omap_dss_find_device_by_port() to
match its new purpose.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/base.c| 13 +
 drivers/gpu/drm/omapdrm/dss/dss-of.c  |  2 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  4 ++--
 drivers/gpu/drm/omapdrm/dss/output.c  | 13 -
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 63fe0a717884..df6cb1ac43c8 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -89,6 +89,19 @@ static bool omapdss_device_is_registered(struct device_node 
*node)
return found;
 }
 
+struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
+   unsigned int port)
+{
+   struct omap_dss_device *dssdev;
+
+   list_for_each_entry(dssdev, _devices_list, list) {
+   if (dssdev->dev->of_node == src && dssdev->port_num == port)
+   return omap_dss_get_device(dssdev);
+   }
+
+   return NULL;
+}
+
 /* 
-
  * Components Handling
  */
diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c 
b/drivers/gpu/drm/omapdrm/dss/dss-of.c
index b51af09e9111..771b20db2d98 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss-of.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c
@@ -74,7 +74,7 @@ omapdss_of_find_source_for_first_ep(struct device_node *node)
return NULL;
 
/* ... and finally the source. */
-   src = omap_dss_find_output_by_port(src_node, port_number);
+   src = omapdss_find_device_by_port(src_node, port_number);
of_node_put(src_node);
 
return src ? src : ERR_PTR(-EPROBE_DEFER);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 98b116514b51..60ec16570ea0 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -561,6 +561,8 @@ void omapdss_unregister_display(struct omap_dss_device 
*dssdev);
 
 void omapdss_device_register(struct omap_dss_device *dssdev);
 void omapdss_device_unregister(struct omap_dss_device *dssdev);
+struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
+   unsigned int port);
 
 struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
 void omap_dss_put_device(struct omap_dss_device *dssdev);
@@ -574,8 +576,6 @@ int omap_dss_get_num_overlays(void);
 int omapdss_register_output(struct omap_dss_device *output);
 void omapdss_unregister_output(struct omap_dss_device *output);
 struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id);
-struct omap_dss_device *omap_dss_find_output_by_port(struct device_node *src,
-unsigned int port);
 int omapdss_output_set_device(struct omap_dss_device *out,
struct omap_dss_device *dssdev);
 int omapdss_output_unset_device(struct omap_dss_device *out);
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index be254ea42e08..e659c8e5c419 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -122,19 +122,6 @@ struct omap_dss_device *omap_dss_get_output(enum 
omap_dss_output_id id)
 }
 EXPORT_SYMBOL(omap_dss_get_output);
 
-struct omap_dss_device *omap_dss_find_output_by_port(struct device_node *src,
-unsigned int port)
-{
-   struct omap_dss_device *out;
-
-   list_for_each_entry(out, _list, output_list) {
-   if (out->dev->of_node == src && out->port_num == port)
-   return omap_dss_get_device(out);
-   }
-
-   return NULL;
-}
-
 struct omap_dss_device *omapdss_find_output_from_display(struct 
omap_dss_device *dssdev)
 {
while (dssdev->src)
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 26/60] drm/omap: dss: Remove output devices list

2018-03-06 Thread Laurent Pinchart
The output devices list isn't used anymore, all output devices are
accessed through the global devices list. Remove it.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c  |  9 ++-
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c  |  8 ++
 .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c   |  8 ++
 drivers/gpu/drm/omapdrm/dss/base.c |  2 ++
 drivers/gpu/drm/omapdrm/dss/dpi.c  |  4 +--
 drivers/gpu/drm/omapdrm/dss/dsi.c  |  4 +--
 drivers/gpu/drm/omapdrm/dss/hdmi4.c|  4 +--
 drivers/gpu/drm/omapdrm/dss/hdmi5.c|  4 +--
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  5 
 drivers/gpu/drm/omapdrm/dss/output.c   | 29 --
 drivers/gpu/drm/omapdrm/dss/sdi.c  |  4 +--
 drivers/gpu/drm/omapdrm/dss/venc.c |  4 +--
 12 files changed, 20 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index c9c744e0c92e..c1ed4e2ce8f3 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -146,7 +146,6 @@ static int opa362_probe(struct platform_device *pdev)
struct panel_drv_data *ddata;
struct omap_dss_device *dssdev;
struct gpio_desc *gpio;
-   int r;
 
dev_dbg(>dev, "probe\n");
 
@@ -169,11 +168,7 @@ static int opa362_probe(struct platform_device *pdev)
dssdev->output_type = OMAP_DISPLAY_TYPE_VENC;
dssdev->owner = THIS_MODULE;
 
-   r = omapdss_register_output(dssdev);
-   if (r) {
-   dev_err(>dev, "Failed to register output\n");
-   return r;
-   }
+   omapdss_device_register(dssdev);
 
return 0;
 }
@@ -183,7 +178,7 @@ static int __exit opa362_remove(struct platform_device 
*pdev)
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *dssdev = >dssdev;
 
-   omapdss_unregister_output(>dssdev);
+   omapdss_device_unregister(>dssdev);
 
WARN_ON(omapdss_device_is_enabled(dssdev));
if (omapdss_device_is_enabled(dssdev))
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index f568e53a9104..b360a68f074d 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -192,11 +192,7 @@ static int tfp410_probe(struct platform_device *pdev)
dssdev->owner = THIS_MODULE;
dssdev->port_num = 1;
 
-   r = omapdss_register_output(dssdev);
-   if (r) {
-   dev_err(>dev, "Failed to register output\n");
-   return r;
-   }
+   omapdss_device_register(dssdev);
 
return 0;
 }
@@ -206,7 +202,7 @@ static int __exit tfp410_remove(struct platform_device 
*pdev)
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *dssdev = >dssdev;
 
-   omapdss_unregister_output(>dssdev);
+   omapdss_device_unregister(>dssdev);
 
WARN_ON(omapdss_device_is_enabled(dssdev));
if (omapdss_device_is_enabled(dssdev))
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
index b15b83108833..6dc5b4b8b5ac 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
@@ -292,11 +292,7 @@ static int tpd_probe(struct platform_device *pdev)
dssdev->owner = THIS_MODULE;
dssdev->port_num = 1;
 
-   r = omapdss_register_output(dssdev);
-   if (r) {
-   dev_err(>dev, "Failed to register output\n");
-   return r;
-   }
+   omapdss_device_register(dssdev);
 
return 0;
 }
@@ -306,7 +302,7 @@ static int __exit tpd_remove(struct platform_device *pdev)
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *dssdev = >dssdev;
 
-   omapdss_unregister_output(>dssdev);
+   omapdss_device_unregister(>dssdev);
 
WARN_ON(omapdss_device_is_enabled(dssdev));
if (omapdss_device_is_enabled(dssdev))
diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 810dcddded8a..7cd3076c2140 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -63,6 +63,7 @@ void omapdss_device_register(struct omap_dss_device *dssdev)
list_add_tail(>list, _devices_list);
mutex_unlock(_devices_lock);
 }
+EXPORT_SYMBOL_GPL(omapdss_device_register);
 
 void omapdss_device_unregister(struct omap_dss_device *dssdev)
 {
@@ -70,6 +71,7 @@ void omapdss_device_unregister(struct omap_dss_device *dssdev)
list_del(>list);
mutex_unlock(_devices_lock);
 }

[PATCH/RFC 12/60] drm/omap: displays: Remove videomode from omap_dss_device structure

2018-03-06 Thread Laurent Pinchart
The omap_dss_device structure stores a videomode. All the connector and
panel drivers that use omap_dss_device also store the videomode in their
own panel_drv_data structures. There's no need to duplicate, remove the
videomode field from omap_dss_device.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c  | 2 --
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c| 2 --
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c   | 2 --
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c   | 1 -
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c   | 1 -
 drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c| 1 -
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c| 2 --
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 8 +++-
 drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c | 2 --
 drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c | 2 --
 drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c  | 2 --
 drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c | 2 --
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c | 2 --
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c | 2 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h   | 2 --
 15 files changed, 3 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index a49bc4a8dcae..6b640ede6614 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -132,7 +132,6 @@ static void tvc_set_timings(struct omap_dss_device *dssdev,
struct omap_dss_device *in = ddata->in;
 
ddata->vm = *vm;
-   dssdev->panel.vm = *vm;
 
in->ops.atv->set_timings(in, vm);
 }
@@ -186,7 +185,6 @@ static int tvc_probe(struct platform_device *pdev)
dssdev->dev = >dev;
dssdev->type = OMAP_DISPLAY_TYPE_VENC;
dssdev->owner = THIS_MODULE;
-   dssdev->panel.vm = tvc_pal_vm;
 
r = omapdss_register_display(dssdev);
if (r) {
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index c320f3c5ae6c..84598ea12a9b 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -139,7 +139,6 @@ static void dvic_set_timings(struct omap_dss_device *dssdev,
struct omap_dss_device *in = ddata->in;
 
ddata->vm = *vm;
-   dssdev->panel.vm = *vm;
 
in->ops.dvi->set_timings(in, vm);
 }
@@ -403,7 +402,6 @@ static int dvic_probe(struct platform_device *pdev)
dssdev->dev = >dev;
dssdev->type = OMAP_DISPLAY_TYPE_DVI;
dssdev->owner = THIS_MODULE;
-   dssdev->panel.vm = dvic_default_vm;
 
r = omapdss_register_display(dssdev);
if (r) {
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 07ab3956f53c..b9f9f6c97f37 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -142,7 +142,6 @@ static void hdmic_set_timings(struct omap_dss_device 
*dssdev,
struct omap_dss_device *in = ddata->in;
 
ddata->vm = *vm;
-   dssdev->panel.vm = *vm;
 
in->ops.hdmi->set_timings(in, vm);
 }
@@ -358,7 +357,6 @@ static int hdmic_probe(struct platform_device *pdev)
dssdev->dev = >dev;
dssdev->type = OMAP_DISPLAY_TYPE_HDMI;
dssdev->owner = THIS_MODULE;
-   dssdev->panel.vm = hdmic_default_vm;
 
r = omapdss_register_display(dssdev);
if (r) {
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index 27d63a14efe3..0e3f4a20e531 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -143,7 +143,6 @@ static void opa362_set_timings(struct omap_dss_device 
*dssdev,
dev_dbg(dssdev->dev, "set_timings\n");
 
ddata->vm = *vm;
-   dssdev->panel.vm = *vm;
 
in->ops.atv->set_timings(in, vm);
 }
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index 566c63a3ad59..08e63e39d0b7 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -137,7 +137,6 @@ static void tfp410_set_timings(struct omap_dss_device 
*dssdev,
tfp410_fix_timings(vm);
 
ddata->vm = *vm;
-   dssdev->panel.vm = *vm;
 
in->ops.dpi->set_timings(in, vm);
 }
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
index ef2821243d67..f6974f4146c0 100644
--- 

[PATCH/RFC 25/60] drm/omap: Move DSI debugfs clocks dump to dsi%u_clks files

2018-03-06 Thread Laurent Pinchart
The DSI clocks are dumped in the DSS-level debugfs clocks file. This
complicates the implementation as the DSI private data has to be looked
up through the outputs list. Simplify it by creating two debugfs files,
dsi1_clks and dsi2_clks, to dump the DSI clocks.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 43 ---
 drivers/gpu/drm/omapdrm/dss/dss.c |  3 ---
 drivers/gpu/drm/omapdrm/dss/dss.h |  2 --
 3 files changed, 9 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 9952803b58d2..adfda2a63ada 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -403,6 +403,7 @@ struct dsi_data {
struct {
struct dss_debugfs_entry *irqs;
struct dss_debugfs_entry *regs;
+   struct dss_debugfs_entry *clks;
} debugfs;
 
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
@@ -442,27 +443,6 @@ static inline struct dsi_data *to_dsi_data(struct 
omap_dss_device *dssdev)
return dev_get_drvdata(dssdev->dev);
 }
 
-static struct dsi_data *dsi_get_dsi_from_id(int module)
-{
-   struct omap_dss_device *out;
-   enum omap_dss_output_id id;
-
-   switch (module) {
-   case 0:
-   id = OMAP_DSS_OUTPUT_DSI1;
-   break;
-   case 1:
-   id = OMAP_DSS_OUTPUT_DSI2;
-   break;
-   default:
-   return NULL;
-   }
-
-   out = omap_dss_get_output(id);
-
-   return out ? to_dsi_data(out) : NULL;
-}
-
 static inline void dsi_write_reg(struct dsi_data *dsi,
 const struct dsi_reg idx, u32 val)
 {
@@ -1448,8 +1428,9 @@ static void dsi_pll_disable(struct dss_pll *pll)
dsi_pll_uninit(dsi, true);
 }
 
-static void dsi_dump_dsi_clocks(struct dsi_data *dsi, struct seq_file *s)
+static int dsi_dump_dsi_clocks(struct seq_file *s, void *p)
 {
+   struct dsi_data *dsi = p;
struct dss_pll_clock_info *cinfo = >pll.cinfo;
enum dss_clk_source dispc_clk_src, dsi_clk_src;
int dsi_module = dsi->module_id;
@@ -1459,7 +1440,7 @@ static void dsi_dump_dsi_clocks(struct dsi_data *dsi, 
struct seq_file *s)
dsi_clk_src = dss_get_dsi_clk_source(dsi->dss, dsi_module);
 
if (dsi_runtime_get(dsi))
-   return;
+   return 0;
 
seq_printf(s,   "- DSI%d PLL -\n", dsi_module + 1);
 
@@ -1503,18 +1484,8 @@ static void dsi_dump_dsi_clocks(struct dsi_data *dsi, 
struct seq_file *s)
seq_printf(s,   "LP_CLK\t\t%lu\n", dsi->current_lp_cinfo.lp_clk);
 
dsi_runtime_put(dsi);
-}
-
-void dsi_dump_clocks(struct seq_file *s)
-{
-   struct dsi_data *dsi;
-   int i;
 
-   for  (i = 0; i < MAX_NUM_DSI; i++) {
-   dsi = dsi_get_dsi_from_id(i);
-   if (dsi)
-   dsi_dump_dsi_clocks(dsi, s);
-   }
+   return 0;
 }
 
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
@@ -5426,6 +5397,9 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
dsi->debugfs.irqs = dss_debugfs_create_file(dss, name,
dsi_dump_dsi_irqs, );
 #endif
+   snprintf(name, sizeof(name), "dsi%u_clks", dsi->module_id + 1);
+   dsi->debugfs.clks = dss_debugfs_create_file(dss, name,
+   dsi_dump_dsi_clocks, );
 
return 0;
 
@@ -5442,6 +5416,7 @@ static void dsi_unbind(struct device *dev, struct device 
*master, void *data)
 {
struct dsi_data *dsi = dev_get_drvdata(dev);
 
+   dss_debugfs_remove_file(dsi->debugfs.clks);
dss_debugfs_remove_file(dsi->debugfs.irqs);
dss_debugfs_remove_file(dsi->debugfs.regs);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 5f7789cf43c7..acafc6077a80 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -895,9 +895,6 @@ static int dss_debug_dump_clocks(struct seq_file *s, void 
*p)
 
dss_dump_clocks(dss, s);
dispc_dump_clocks(dss->dispc, s);
-#ifdef CONFIG_OMAP2_DSS_DSI
-   dsi_dump_clocks(s);
-#endif
return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index 73f5e8fc18cf..ea850b9c5e7c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -373,8 +373,6 @@ static inline void sdi_uninit_port(struct device_node *port)
 
 #ifdef CONFIG_OMAP2_DSS_DSI
 
-void dsi_dump_clocks(struct seq_file *s);
-
 void dsi_irq_handler(void);
 
 #endif
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 16/60] drm/omap: dss: Create and use omapdss_device_is_registered()

2018-03-06 Thread Laurent Pinchart
The omapdss_component_is_loaded() function test whether a component is
loaded by checking whether it is present in the displays list or the
outputs list. Simplify the implementation by checking for the component
in the global omap_dss_device list.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/base.c| 22 +++---
 drivers/gpu/drm/omapdrm/dss/display.c | 18 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 ---
 drivers/gpu/drm/omapdrm/dss/output.c  | 13 -
 4 files changed, 19 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 18b72d7c717a..63fe0a717884 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -71,6 +71,24 @@ void omapdss_device_unregister(struct omap_dss_device 
*dssdev)
mutex_unlock(_devices_lock);
 }
 
+static bool omapdss_device_is_registered(struct device_node *node)
+{
+   struct omap_dss_device *dssdev;
+   bool found = false;
+
+   mutex_lock(_devices_lock);
+
+   list_for_each_entry(dssdev, _devices_list, list) {
+   if (dssdev->dev->of_node == node) {
+   found = true;
+   break;
+   }
+   }
+
+   mutex_unlock(_devices_lock);
+   return found;
+}
+
 /* 
-
  * Components Handling
  */
@@ -157,9 +175,7 @@ static bool omapdss_component_is_loaded(struct 
omapdss_comp_node *comp)
 {
if (comp->dss_core_component)
return true;
-   if (omapdss_component_is_display(comp->node))
-   return true;
-   if (omapdss_component_is_output(comp->node))
+   if (omapdss_device_is_registered(comp->node))
return true;
 
return false;
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c 
b/drivers/gpu/drm/omapdrm/dss/display.c
index eacbbf45f737..383512c8a466 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -72,24 +72,6 @@ void omapdss_unregister_display(struct omap_dss_device 
*dssdev)
 }
 EXPORT_SYMBOL(omapdss_unregister_display);
 
-bool omapdss_component_is_display(struct device_node *node)
-{
-   struct omap_dss_device *dssdev;
-   bool found = false;
-
-   mutex_lock(_list_mutex);
-   list_for_each_entry(dssdev, _list, panel_list) {
-   if (dssdev->dev->of_node == node) {
-   found = true;
-   goto out;
-   }
-   }
-out:
-   mutex_unlock(_list_mutex);
-   return found;
-}
-EXPORT_SYMBOL(omapdss_component_is_display);
-
 struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev)
 {
if (!try_module_get(dssdev->owner))
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index ddef6f39ca99..320cf3383580 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -735,9 +735,6 @@ struct dispc_ops {
 struct dispc_device *dispc_get_dispc(struct dss_device *dss);
 const struct dispc_ops *dispc_get_ops(struct dss_device *dss);
 
-bool omapdss_component_is_display(struct device_node *node);
-bool omapdss_component_is_output(struct device_node *node);
-
 bool omapdss_stack_is_ready(void);
 void omapdss_gather_components(struct device *dev);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index 1a2d24906edd..7f18153a1bde 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -109,19 +109,6 @@ void omapdss_unregister_output(struct omap_dss_device *out)
 }
 EXPORT_SYMBOL(omapdss_unregister_output);
 
-bool omapdss_component_is_output(struct device_node *node)
-{
-   struct omap_dss_device *out;
-
-   list_for_each_entry(out, _list, output_list) {
-   if (out->dev->of_node == node)
-   return true;
-   }
-
-   return false;
-}
-EXPORT_SYMBOL(omapdss_component_is_output);
-
 struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id)
 {
struct omap_dss_device *out;
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 20/60] drm/omap: dss: Add functions to connect and disconnect devices

2018-03-06 Thread Laurent Pinchart
The omap_dss_device objects model display components and are connected
at runtime to create display pipelines. The connect and disconnect
operations implemented by each component contain lots of duplicate code.
As a first step towards fixing this, create new functions to wrap the
direct calls to those operations and use them.

Signed-off-by: Laurent Pinchart 
---
 .../gpu/drm/omapdrm/displays/connector-analog-tv.c   |  4 ++--
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c |  4 ++--
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c|  4 ++--
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c|  4 ++--
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c|  4 ++--
 drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c |  4 ++--
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c |  4 ++--
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c  |  6 +++---
 .../drm/omapdrm/displays/panel-lgphilips-lb035q02.c  |  4 ++--
 .../gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c  |  4 ++--
 .../drm/omapdrm/displays/panel-sharp-ls037v7dw01.c   |  4 ++--
 .../gpu/drm/omapdrm/displays/panel-sony-acx565akm.c  |  4 ++--
 .../gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c  |  4 ++--
 .../gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c  |  4 ++--
 drivers/gpu/drm/omapdrm/dss/base.c   | 20 
 drivers/gpu/drm/omapdrm/dss/omapdss.h|  4 
 drivers/gpu/drm/omapdrm/omap_drv.c   |  4 ++--
 17 files changed, 55 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index a94868d9398b..41ba3c5dbe7d 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -59,7 +59,7 @@ static int tvc_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in);
}
 
-   r = in->ops->connect(in, dssdev);
+   r = omapdss_device_connect(in, dssdev);
if (r) {
omap_dss_put_device(in);
return r;
@@ -79,7 +79,7 @@ static void tvc_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev))
return;
 
-   in->ops->disconnect(in, dssdev);
+   omapdss_device_disconnect(in, dssdev);
 
omap_dss_put_device(in);
ddata->in = NULL;
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 021e3b651c89..f193bbda550c 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -72,7 +72,7 @@ static int dvic_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in);
}
 
-   r = in->ops->connect(in, dssdev);
+   r = omapdss_device_connect(in, dssdev);
if (r) {
omap_dss_put_device(in);
return r;
@@ -90,7 +90,7 @@ static void dvic_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev))
return;
 
-   in->ops->disconnect(in, dssdev);
+   omapdss_device_disconnect(in, dssdev);
 
omap_dss_put_device(in);
ddata->in = NULL;
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index bcfb64bad8f4..480fbd6fac1e 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -69,7 +69,7 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
return PTR_ERR(in);
}
 
-   r = in->ops->connect(in, dssdev);
+   r = omapdss_device_connect(in, dssdev);
if (r) {
omap_dss_put_device(in);
return r;
@@ -89,7 +89,7 @@ static void hdmic_disconnect(struct omap_dss_device *dssdev)
if (!omapdss_device_is_connected(dssdev))
return;
 
-   in->ops->disconnect(in, dssdev);
+   omapdss_device_disconnect(in, dssdev);
 
omap_dss_put_device(in);
ddata->in = NULL;
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index 37982ffe0ad4..752b565987c1 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -50,7 +50,7 @@ static int opa362_connect(struct omap_dss_device *dssdev,
return PTR_ERR(in);
}
 
-   r = in->ops->connect(in, dssdev);
+   r = omapdss_device_connect(in, dssdev);
if (r) {
omap_dss_put_device(in);
return r;
@@ -82,7 +82,7 @@ static void opa362_disconnect(struct omap_dss_device *dssdev,
dst->src = NULL;
dssdev->dst = NULL;
 
-   in->ops->disconnect(in, >dssdev);
+   omapdss_device_disconnect(in, >dssdev);
 

[PATCH/RFC 31/60] drm/omap: dss: Move and rename omap_dss_(get|put)_device()

2018-03-06 Thread Laurent Pinchart
The functions operate on any omap_dss_device, move them from display.c
to base.c. While at it rename them to match the naming of the other
functions operating on struct omap_dss_device.

Signed-off-by: Laurent Pinchart 
---
 .../gpu/drm/omapdrm/displays/connector-analog-tv.c |  4 ++--
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c   |  4 ++--
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c  |  4 ++--
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c  |  4 ++--
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c  |  4 ++--
 .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c   |  4 ++--
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c   |  4 ++--
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c|  4 ++--
 .../omapdrm/displays/panel-lgphilips-lb035q02.c|  4 ++--
 .../drm/omapdrm/displays/panel-nec-nl8048hl11.c|  4 ++--
 .../drm/omapdrm/displays/panel-sharp-ls037v7dw01.c |  4 ++--
 .../drm/omapdrm/displays/panel-sony-acx565akm.c|  4 ++--
 .../drm/omapdrm/displays/panel-tpo-td028ttec1.c|  4 ++--
 .../drm/omapdrm/displays/panel-tpo-td043mtea1.c|  4 ++--
 drivers/gpu/drm/omapdrm/dss/base.c | 27 +++---
 drivers/gpu/drm/omapdrm/dss/display.c  | 24 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  5 ++--
 drivers/gpu/drm/omapdrm/dss/output.c   |  2 +-
 drivers/gpu/drm/omapdrm/omap_connector.c   |  4 ++--
 drivers/gpu/drm/omapdrm/omap_crtc.c|  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c |  8 +++
 21 files changed, 62 insertions(+), 66 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index f1d1c67d72b8..a7eb25bd9283 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -55,7 +55,7 @@ static int tvc_connect(struct omap_dss_device *dssdev)
 
r = omapdss_device_connect(src, dssdev);
if (r) {
-   omap_dss_put_device(src);
+   omapdss_device_put(src);
return r;
}
 
@@ -68,7 +68,7 @@ static void tvc_disconnect(struct omap_dss_device *dssdev)
 
omapdss_device_disconnect(src, dssdev);
 
-   omap_dss_put_device(src);
+   omapdss_device_put(src);
 }
 
 static int tvc_enable(struct omap_dss_device *dssdev)
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 9e0b5a0b2eea..3e71af9ba0c3 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -69,7 +69,7 @@ static int dvic_connect(struct omap_dss_device *dssdev)
 
r = omapdss_device_connect(src, dssdev);
if (r) {
-   omap_dss_put_device(src);
+   omapdss_device_put(src);
return r;
}
 
@@ -82,7 +82,7 @@ static void dvic_disconnect(struct omap_dss_device *dssdev)
 
omapdss_device_disconnect(src, dssdev);
 
-   omap_dss_put_device(src);
+   omapdss_device_put(src);
 }
 
 static int dvic_enable(struct omap_dss_device *dssdev)
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 882883f811fb..4fbc1ba84bee 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -65,7 +65,7 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
 
r = omapdss_device_connect(src, dssdev);
if (r) {
-   omap_dss_put_device(src);
+   omapdss_device_put(src);
return r;
}
 
@@ -78,7 +78,7 @@ static void hdmic_disconnect(struct omap_dss_device *dssdev)
 
omapdss_device_disconnect(src, dssdev);
 
-   omap_dss_put_device(src);
+   omapdss_device_put(src);
 }
 
 static int hdmic_enable(struct omap_dss_device *dssdev)
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index c1ed4e2ce8f3..01b00eea3a98 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -45,7 +45,7 @@ static int opa362_connect(struct omap_dss_device *dssdev,
 
r = omapdss_device_connect(src, dssdev);
if (r) {
-   omap_dss_put_device(src);
+   omapdss_device_put(src);
return r;
}
 
@@ -60,7 +60,7 @@ static void opa362_disconnect(struct omap_dss_device *dssdev,
 
omapdss_device_disconnect(src, >dssdev);
 
-   omap_dss_put_device(src);
+   omapdss_device_put(src);
 }
 
 static int opa362_enable(struct omap_dss_device *dssdev)
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index b360a68f074d..6f71d2b7de03 100644
--- 

[PATCH/RFC 11/60] drm/omap: dss: Constify omap_dss_driver operations structure

2018-03-06 Thread Laurent Pinchart
The structure contains function pointers that don't need to be modified.
Make all its instances const to improve security.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c  | 2 +-
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c| 2 +-
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c   | 2 +-
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c| 2 +-
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 2 +-
 drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c | 2 +-
 drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c | 2 +-
 drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c  | 2 +-
 drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c | 2 +-
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c | 2 +-
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c | 2 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h   | 2 +-
 drivers/gpu/drm/omapdrm/omap_connector.c| 6 +++---
 drivers/gpu/drm/omapdrm/omap_encoder.c  | 6 +++---
 14 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index 5fdecc12b608..a49bc4a8dcae 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -154,7 +154,7 @@ static int tvc_check_timings(struct omap_dss_device *dssdev,
return in->ops.atv->check_timings(in, vm);
 }
 
-static struct omap_dss_driver tvc_driver = {
+static const struct omap_dss_driver tvc_driver = {
.connect= tvc_connect,
.disconnect = tvc_disconnect,
 
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 6d8cbd9e2110..c320f3c5ae6c 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -297,7 +297,7 @@ static void dvic_disable_hpd(struct omap_dss_device *dssdev)
mutex_unlock(>hpd_lock);
 }
 
-static struct omap_dss_driver dvic_driver = {
+static const struct omap_dss_driver dvic_driver = {
.connect= dvic_connect,
.disconnect = dvic_disconnect,
 
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 71a6121f1ed9..07ab3956f53c 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -260,7 +260,7 @@ static int hdmic_set_hdmi_mode(struct omap_dss_device 
*dssdev, bool hdmi_mode)
return in->ops.hdmi->set_hdmi_mode(in, hdmi_mode);
 }
 
-static struct omap_dss_driver hdmic_driver = {
+static const struct omap_dss_driver hdmic_driver = {
.connect= hdmic_connect,
.disconnect = hdmic_disconnect,
 
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
index 6cbf570d6727..e874f0b72798 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
@@ -153,7 +153,7 @@ static int panel_dpi_check_timings(struct omap_dss_device 
*dssdev,
return in->ops.dpi->check_timings(in, vm);
 }
 
-static struct omap_dss_driver panel_dpi_ops = {
+static const struct omap_dss_driver panel_dpi_ops = {
.connect= panel_dpi_connect,
.disconnect = panel_dpi_disconnect,
 
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 428de90fced1..d7c57d84d7bd 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -1210,7 +1210,7 @@ static void dsicm_get_size(struct omap_dss_device *dssdev,
*height = ddata->height_mm;
 }
 
-static struct omap_dss_driver dsicm_ops = {
+static const struct omap_dss_driver dsicm_ops = {
.connect= dsicm_connect,
.disconnect = dsicm_disconnect,
 
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c 
b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
index 754197099440..ad98d2ffcf1b 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
@@ -228,7 +228,7 @@ static int lb035q02_check_timings(struct omap_dss_device 
*dssdev,
return in->ops.dpi->check_timings(in, vm);
 }
 
-static struct omap_dss_driver lb035q02_ops = {
+static const struct omap_dss_driver lb035q02_ops = {
.connect= lb035q02_connect,
.disconnect = lb035q02_disconnect,
 
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c 
b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
index 

[PATCH/RFC 10/60] drm/omap: dss: Remove unused omapdss_default_get_timings()

2018-03-06 Thread Laurent Pinchart
All omap_dss_driver instances provide the get_timings operation. Remove
the default function.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/display.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/display.c 
b/drivers/gpu/drm/omapdrm/dss/display.c
index 25c3be86d7f4..e07e3319d6e0 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -28,19 +28,12 @@
 
 #include "omapdss.h"
 
-static void omapdss_default_get_timings(struct omap_dss_device *dssdev,
-   struct videomode *vm)
-{
-   *vm = dssdev->panel.vm;
-}
-
 static LIST_HEAD(panel_list);
 static DEFINE_MUTEX(panel_list_mutex);
 static int disp_num_counter;
 
 int omapdss_register_display(struct omap_dss_device *dssdev)
 {
-   struct omap_dss_driver *drv = dssdev->driver;
int id;
 
/*
@@ -60,9 +53,6 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
dssdev->name = devm_kasprintf(dssdev->dev, GFP_KERNEL,
  "display%u", id);
 
-   if (drv && drv->get_timings == NULL)
-   drv->get_timings = omapdss_default_get_timings;
-
mutex_lock(_list_mutex);
list_add_tail(>panel_list, _list);
mutex_unlock(_list_mutex);
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 15/60] drm/omap: dss: Create global list of all omap_dss_device instances

2018-03-06 Thread Laurent Pinchart
The omap_dss_device instances are stored in two separate lists,
depending on whether they are panels or outputs. Create a third list
that stores all omap_dss_device instances to allow generic code to
operate on all instances.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/base.c| 45 ---
 drivers/gpu/drm/omapdrm/dss/display.c |  4 
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  4 
 drivers/gpu/drm/omapdrm/dss/output.c  |  2 ++
 4 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 99e8cb8dc65b..18b72d7c717a 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -14,24 +14,17 @@
  */
 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
-#include 
 
 #include "dss.h"
 #include "omapdss.h"
 
 static struct dss_device *dss_device;
 
-static struct list_head omapdss_comp_list;
-
-struct omapdss_comp_node {
-   struct list_head list;
-   struct device_node *node;
-   bool dss_core_component;
-};
-
 struct dss_device *omapdss_get_dss(void)
 {
return dss_device;
@@ -56,6 +49,40 @@ const struct dispc_ops *dispc_get_ops(struct dss_device *dss)
 }
 EXPORT_SYMBOL(dispc_get_ops);
 
+
+/* 
-
+ * OMAP DSS Devices Handling
+ */
+
+static LIST_HEAD(omapdss_devices_list);
+static DEFINE_MUTEX(omapdss_devices_lock);
+
+void omapdss_device_register(struct omap_dss_device *dssdev)
+{
+   mutex_lock(_devices_lock);
+   list_add_tail(>list, _devices_list);
+   mutex_unlock(_devices_lock);
+}
+
+void omapdss_device_unregister(struct omap_dss_device *dssdev)
+{
+   mutex_lock(_devices_lock);
+   list_del(>list);
+   mutex_unlock(_devices_lock);
+}
+
+/* 
-
+ * Components Handling
+ */
+
+static struct list_head omapdss_comp_list;
+
+struct omapdss_comp_node {
+   struct list_head list;
+   struct device_node *node;
+   bool dss_core_component;
+};
+
 static bool omapdss_list_contains(const struct device_node *node)
 {
struct omapdss_comp_node *comp;
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c 
b/drivers/gpu/drm/omapdrm/dss/display.c
index e07e3319d6e0..eacbbf45f737 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -56,6 +56,8 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
mutex_lock(_list_mutex);
list_add_tail(>panel_list, _list);
mutex_unlock(_list_mutex);
+
+   omapdss_device_register(dssdev);
return 0;
 }
 EXPORT_SYMBOL(omapdss_register_display);
@@ -65,6 +67,8 @@ void omapdss_unregister_display(struct omap_dss_device 
*dssdev)
mutex_lock(_list_mutex);
list_del(>panel_list);
mutex_unlock(_list_mutex);
+
+   omapdss_device_register(dssdev);
 }
 EXPORT_SYMBOL(omapdss_unregister_display);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 9f6c0385b7de..ddef6f39ca99 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -448,6 +448,7 @@ struct omap_dss_device {
 
struct module *owner;
 
+   struct list_head list;
struct list_head panel_list;
 
unsigned int alias_id;
@@ -558,6 +559,9 @@ static inline bool omapdss_is_initialized(void)
 int omapdss_register_display(struct omap_dss_device *dssdev);
 void omapdss_unregister_display(struct omap_dss_device *dssdev);
 
+void omapdss_device_register(struct omap_dss_device *dssdev);
+void omapdss_device_unregister(struct omap_dss_device *dssdev);
+
 struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
 void omap_dss_put_device(struct omap_dss_device *dssdev);
 #define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index 0fcd13ea8824..1a2d24906edd 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -97,6 +97,7 @@ EXPORT_SYMBOL(omapdss_output_unset_device);
 int omapdss_register_output(struct omap_dss_device *out)
 {
list_add_tail(>output_list, _list);
+   omapdss_device_register(out);
return 0;
 }
 EXPORT_SYMBOL(omapdss_register_output);
@@ -104,6 +105,7 @@ EXPORT_SYMBOL(omapdss_register_output);
 void omapdss_unregister_output(struct omap_dss_device *out)
 {
list_del(>output_list);
+   omapdss_device_unregister(out);
 }
 EXPORT_SYMBOL(omapdss_unregister_output);
 
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 23/60] drm/omap: displays: Remove input omap_dss_device from panel data

2018-03-06 Thread Laurent Pinchart
All connectors, encoders and panels store a pointer to their input
omap_dss_device in the panel driver data structure. This duplicates the
src field in the omap_dss_device structure. Remove the private copy and
use the src field.

Signed-off-by: Laurent Pinchart 
---
 .../gpu/drm/omapdrm/displays/connector-analog-tv.c |  41 ++---
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c   |  43 ++---
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c  |  83 +
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c  |  41 ++---
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c  |  41 ++---
 .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c   |  63 +++
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c   |  44 +++--
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c| 190 ++---
 .../omapdrm/displays/panel-lgphilips-lb035q02.c|  41 ++---
 .../drm/omapdrm/displays/panel-nec-nl8048hl11.c|  42 ++---
 .../drm/omapdrm/displays/panel-sharp-ls037v7dw01.c |  42 ++---
 .../drm/omapdrm/displays/panel-sony-acx565akm.c|  42 ++---
 .../drm/omapdrm/displays/panel-tpo-td028ttec1.c|  42 ++---
 .../drm/omapdrm/displays/panel-tpo-td043mtea1.c|  44 +++--
 14 files changed, 358 insertions(+), 441 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index d77e21fc26ad..f579bd9ce7cb 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -18,7 +18,6 @@
 
 struct panel_drv_data {
struct omap_dss_device dssdev;
-   struct omap_dss_device *in;
 
struct device *dev;
 
@@ -45,40 +44,37 @@ static const struct videomode tvc_pal_vm = {
 static int tvc_connect(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in;
+   struct omap_dss_device *src;
int r;
 
-   in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
-   if (IS_ERR(in)) {
+   src = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
+   if (IS_ERR(src)) {
dev_err(ddata->dev, "failed to find video source\n");
-   return PTR_ERR(in);
+   return PTR_ERR(src);
}
 
-   r = omapdss_device_connect(in, dssdev);
+   r = omapdss_device_connect(src, dssdev);
if (r) {
-   omap_dss_put_device(in);
+   omap_dss_put_device(src);
return r;
}
 
-   ddata->in = in;
return 0;
 }
 
 static void tvc_disconnect(struct omap_dss_device *dssdev)
 {
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
+   struct omap_dss_device *src = dssdev->src;
 
-   omapdss_device_disconnect(in, dssdev);
+   omapdss_device_disconnect(src, dssdev);
 
-   omap_dss_put_device(in);
-   ddata->in = NULL;
+   omap_dss_put_device(src);
 }
 
 static int tvc_enable(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
+   struct omap_dss_device *src = dssdev->src;
int r;
 
dev_dbg(ddata->dev, "enable\n");
@@ -89,9 +85,9 @@ static int tvc_enable(struct omap_dss_device *dssdev)
if (omapdss_device_is_enabled(dssdev))
return 0;
 
-   in->ops->set_timings(in, >vm);
+   src->ops->set_timings(src, >vm);
 
-   r = in->ops->enable(in);
+   r = src->ops->enable(src);
if (r)
return r;
 
@@ -103,14 +99,14 @@ static int tvc_enable(struct omap_dss_device *dssdev)
 static void tvc_disable(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
+   struct omap_dss_device *src = dssdev->src;
 
dev_dbg(ddata->dev, "disable\n");
 
if (!omapdss_device_is_enabled(dssdev))
return;
 
-   in->ops->disable(in);
+   src->ops->disable(src);
 
dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
 }
@@ -119,11 +115,11 @@ static void tvc_set_timings(struct omap_dss_device 
*dssdev,
struct videomode *vm)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
+   struct omap_dss_device *src = dssdev->src;
 
ddata->vm = *vm;
 
-   in->ops->set_timings(in, vm);
+   src->ops->set_timings(src, vm);
 }
 
 static void tvc_get_timings(struct omap_dss_device *dssdev,
@@ -137,10 +133,9 @@ static void tvc_get_timings(struct omap_dss_device *dssdev,
 static int tvc_check_timings(struct omap_dss_device *dssdev,
 struct videomode *vm)
 {
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
+   struct 

[PATCH/RFC 17/60] drm/omap: dss: Rework output lookup by port node

2018-03-06 Thread Laurent Pinchart
The omap_dss_find_output_by_port_node() function defined in output.c
looks up an output from its port node. To do so it needs to call helper
functions from dss-of.c to lookup the port parent and the port number.
As omap_dss_find_output_by_port_node() is only called by
omapdss_of_find_source_for_first_ep() from dss-of.c this goes back and
forth between the to source files and isn't very clear.

Simplify the code by passing both the parent and the port number to
omap_dss_find_output_by_port_node() instead of the port node, and rename
the function to omap_dss_find_output_by_port().

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dss-of.c  | 39 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  6 ++
 drivers/gpu/drm/omapdrm/dss/output.c  | 17 +++
 3 files changed, 23 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c 
b/drivers/gpu/drm/omapdrm/dss/dss-of.c
index 4602a79c6c44..b51af09e9111 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss-of.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c
@@ -21,7 +21,8 @@
 
 #include "omapdss.h"
 
-struct device_node *dss_of_port_get_parent_device(struct device_node *port)
+static struct device_node *
+dss_of_port_get_parent_device(struct device_node *port)
 {
struct device_node *np;
int i;
@@ -45,40 +46,36 @@ struct device_node *dss_of_port_get_parent_device(struct 
device_node *port)
return NULL;
 }
 
-u32 dss_of_port_get_port_number(struct device_node *port)
-{
-   int r;
-   u32 reg;
-
-   r = of_property_read_u32(port, "reg", );
-   if (r)
-   reg = 0;
-
-   return reg;
-}
-
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node)
 {
-   struct device_node *ep;
+   struct device_node *src_node;
struct device_node *src_port;
+   struct device_node *ep;
struct omap_dss_device *src;
+   u32 port_number = 0;
 
+   /* Get the endpoint... */
ep = of_graph_get_endpoint_by_regs(node, 0, 0);
if (!ep)
return ERR_PTR(-EINVAL);
 
+   /* ... and its remote port... */
src_port = of_graph_get_remote_port(ep);
-   if (!src_port) {
-   of_node_put(ep);
-   return ERR_PTR(-EINVAL);
-   }
-
of_node_put(ep);
+   if (!src_port)
+   return ERR_PTR(-EINVAL);
 
-   src = omap_dss_find_output_by_port_node(src_port);
-
+   /* ... and the remote port's number and parent... */
+   of_property_read_u32(src_port, "reg", _number);
+   src_node = dss_of_port_get_parent_device(src_port);
of_node_put(src_port);
+   if (!src_node)
+   return NULL;
+
+   /* ... and finally the source. */
+   src = omap_dss_find_output_by_port(src_node, port_number);
+   of_node_put(src_node);
 
return src ? src : ERR_PTR(-EPROBE_DEFER);
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 320cf3383580..98b116514b51 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -574,7 +574,8 @@ int omap_dss_get_num_overlays(void);
 int omapdss_register_output(struct omap_dss_device *output);
 void omapdss_unregister_output(struct omap_dss_device *output);
 struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id);
-struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node 
*port);
+struct omap_dss_device *omap_dss_find_output_by_port(struct device_node *src,
+unsigned int port);
 int omapdss_output_set_device(struct omap_dss_device *out,
struct omap_dss_device *dssdev);
 int omapdss_output_unset_device(struct omap_dss_device *out);
@@ -601,9 +602,6 @@ static inline bool omapdss_device_is_enabled(struct 
omap_dss_device *dssdev)
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node);
 
-struct device_node *dss_of_port_get_parent_device(struct device_node *port);
-u32 dss_of_port_get_port_number(struct device_node *port);
-
 enum dss_writeback_channel {
DSS_WB_LCD1_MGR =   0,
DSS_WB_LCD2_MGR =   1,
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index 7f18153a1bde..be254ea42e08 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -122,27 +122,16 @@ struct omap_dss_device *omap_dss_get_output(enum 
omap_dss_output_id id)
 }
 EXPORT_SYMBOL(omap_dss_get_output);
 
-struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node 
*port)
+struct omap_dss_device *omap_dss_find_output_by_port(struct device_node *src,
+unsigned int port)
 {
-   struct device_node *src_node;
struct omap_dss_device *out;
-   u32 reg;
-
-   src_node = 

[PATCH/RFC 08/60] drm/omap: dss: Remove omapdss_atv_ops get_wss and set_wss operations

2018-03-06 Thread Laurent Pinchart
The operations are never used, remove them. If the need to set wide
screen signaling data arises later, it should be implemented by
extending the DRM bridge API.

Signed-off-by: Laurent Pinchart 
---
 .../gpu/drm/omapdrm/displays/connector-analog-tv.c | 19 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  6 
 drivers/gpu/drm/omapdrm/dss/venc.c | 41 --
 3 files changed, 66 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index 9eabd7201a12..5fdecc12b608 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -154,22 +154,6 @@ static int tvc_check_timings(struct omap_dss_device 
*dssdev,
return in->ops.atv->check_timings(in, vm);
 }
 
-static u32 tvc_get_wss(struct omap_dss_device *dssdev)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
-
-   return in->ops.atv->get_wss(in);
-}
-
-static int tvc_set_wss(struct omap_dss_device *dssdev, u32 wss)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
-
-   return in->ops.atv->set_wss(in, wss);
-}
-
 static struct omap_dss_driver tvc_driver = {
.connect= tvc_connect,
.disconnect = tvc_disconnect,
@@ -180,9 +164,6 @@ static struct omap_dss_driver tvc_driver = {
.set_timings= tvc_set_timings,
.get_timings= tvc_get_timings,
.check_timings  = tvc_check_timings,
-
-   .get_wss= tvc_get_wss,
-   .set_wss= tvc_set_wss,
 };
 
 static int tvc_probe(struct platform_device *pdev)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 85fbf41f4650..ca65c749e225 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -362,9 +362,6 @@ struct omapdss_atv_ops {
struct videomode *vm);
void (*get_timings)(struct omap_dss_device *dssdev,
struct videomode *vm);
-
-   int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
-   u32 (*get_wss)(struct omap_dss_device *dssdev);
 };
 
 struct omapdss_hdmi_ops {
@@ -552,9 +549,6 @@ struct omap_dss_driver {
void (*get_size)(struct omap_dss_device *dssdev,
 unsigned int *width, unsigned int *height);
 
-   int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
-   u32 (*get_wss)(struct omap_dss_device *dssdev);
-
int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
bool (*detect)(struct omap_dss_device *dssdev);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c 
b/drivers/gpu/drm/omapdrm/dss/venc.c
index 24d1ced210bd..3f4b8a181d74 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -626,44 +626,6 @@ static void venc_get_timings(struct omap_dss_device 
*dssdev,
mutex_unlock(>venc_lock);
 }
 
-static u32 venc_get_wss(struct omap_dss_device *dssdev)
-{
-   struct venc_device *venc = dssdev_to_venc(dssdev);
-
-   /* Invert due to VENC_L21_WC_CTL:INV=1 */
-   return (venc->wss_data >> 8) ^ 0xf;
-}
-
-static int venc_set_wss(struct omap_dss_device *dssdev, u32 wss)
-{
-   struct venc_device *venc = dssdev_to_venc(dssdev);
-   const struct venc_config *config;
-   int r;
-
-   DSSDBG("venc_set_wss\n");
-
-   mutex_lock(>venc_lock);
-
-   config = venc_timings_to_config(>vm);
-
-   /* Invert due to VENC_L21_WC_CTL:INV=1 */
-   venc->wss_data = (wss ^ 0xf) << 8;
-
-   r = venc_runtime_get(venc);
-   if (r)
-   goto err;
-
-   venc_write_reg(venc, VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data |
-  venc->wss_data);
-
-   venc_runtime_put(venc);
-
-err:
-   mutex_unlock(>venc_lock);
-
-   return r;
-}
-
 static int venc_init_regulator(struct venc_device *venc)
 {
struct regulator *vdda_dac;
@@ -810,9 +772,6 @@ static const struct omapdss_atv_ops venc_ops = {
.check_timings = venc_check_timings,
.set_timings = venc_set_timings,
.get_timings = venc_get_timings,
-
-   .set_wss = venc_set_wss,
-   .get_wss = venc_get_wss,
 };
 
 static void venc_init_output(struct venc_device *venc)
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 13/60] drm/omap: dss: Remove omap_dss_device panel fields

2018-03-06 Thread Laurent Pinchart
The omap_dss_device panel.dsi_pix_fmt and panel.dsi_mode fields are
unused. Remove them.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h   | 5 -
 2 files changed, 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 555ab2ac5576..8d98cd628e11 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -1333,7 +1333,6 @@ static int dsicm_probe(struct platform_device *pdev)
dssdev->type = OMAP_DISPLAY_TYPE_DSI;
dssdev->owner = THIS_MODULE;
 
-   dssdev->panel.dsi_pix_fmt = OMAP_DSS_DSI_FMT_RGB888;
dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE |
OMAP_DSS_DISPLAY_CAP_TEAR_ELIM;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 84f0bacf9766..8e81652b82d5 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -455,11 +455,6 @@ struct omap_dss_device {
enum omap_display_type type;
enum omap_display_type output_type;
 
-   struct {
-   enum omap_dss_dsi_pixel_format dsi_pix_fmt;
-   enum omap_dss_dsi_mode dsi_mode;
-   } panel;
-
const char *name;
 
const struct omap_dss_driver *driver;
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 07/60] drm/omap: dss: Remove omapdss_hdmi_ops set_infoframe operation

2018-03-06 Thread Laurent Pinchart
The operation is never used, remove it. If the need to set HDMI
infoframe arises later, it should be implemented by extending the DRM
bridge API.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c| 10 --
 drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c | 10 --
 drivers/gpu/drm/omapdrm/dss/hdmi4.c  | 10 --
 drivers/gpu/drm/omapdrm/dss/hdmi5.c  | 10 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h|  2 --
 5 files changed, 42 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index ca30ed9da7eb..71a6121f1ed9 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -260,15 +260,6 @@ static int hdmic_set_hdmi_mode(struct omap_dss_device 
*dssdev, bool hdmi_mode)
return in->ops.hdmi->set_hdmi_mode(in, hdmi_mode);
 }
 
-static int hdmic_set_infoframe(struct omap_dss_device *dssdev,
-   const struct hdmi_avi_infoframe *avi)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
-
-   return in->ops.hdmi->set_infoframe(in, avi);
-}
-
 static struct omap_dss_driver hdmic_driver = {
.connect= hdmic_connect,
.disconnect = hdmic_disconnect,
@@ -287,7 +278,6 @@ static struct omap_dss_driver hdmic_driver = {
.enable_hpd = hdmic_enable_hpd,
.disable_hpd= hdmic_disable_hpd,
.set_hdmi_mode  = hdmic_set_hdmi_mode,
-   .set_hdmi_infoframe = hdmic_set_infoframe,
 };
 
 static irqreturn_t hdmic_hpd_isr(int irq, void *data)
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
index d275bf152da5..efe608ce0f2a 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
@@ -222,15 +222,6 @@ static void tpd_disable_hpd(struct omap_dss_device *dssdev)
mutex_unlock(>hpd_lock);
 }
 
-static int tpd_set_infoframe(struct omap_dss_device *dssdev,
-   const struct hdmi_avi_infoframe *avi)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
-
-   return in->ops.hdmi->set_infoframe(in, avi);
-}
-
 static int tpd_set_hdmi_mode(struct omap_dss_device *dssdev,
bool hdmi_mode)
 {
@@ -257,7 +248,6 @@ static const struct omapdss_hdmi_ops tpd_hdmi_ops = {
.unregister_hpd_cb  = tpd_unregister_hpd_cb,
.enable_hpd = tpd_enable_hpd,
.disable_hpd= tpd_disable_hpd,
-   .set_infoframe  = tpd_set_infoframe,
.set_hdmi_mode  = tpd_set_hdmi_mode,
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 97c88861d67a..ef31407edc39 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -530,15 +530,6 @@ static void hdmi_lost_hotplug(struct omap_dss_device 
*dssdev)
hdmi4_cec_set_phys_addr(>core, CEC_PHYS_ADDR_INVALID);
 }
 
-static int hdmi_set_infoframe(struct omap_dss_device *dssdev,
-   const struct hdmi_avi_infoframe *avi)
-{
-   struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
-
-   hdmi->cfg.infoframe = *avi;
-   return 0;
-}
-
 static int hdmi_set_hdmi_mode(struct omap_dss_device *dssdev,
bool hdmi_mode)
 {
@@ -561,7 +552,6 @@ static const struct omapdss_hdmi_ops hdmi_ops = {
 
.read_edid  = hdmi_read_edid,
.lost_hotplug   = hdmi_lost_hotplug,
-   .set_infoframe  = hdmi_set_infoframe,
.set_hdmi_mode  = hdmi_set_hdmi_mode,
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index d28da9ac3e90..aac159c93cda 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -522,15 +522,6 @@ static int hdmi_read_edid(struct omap_dss_device *dssdev,
return r;
 }
 
-static int hdmi_set_infoframe(struct omap_dss_device *dssdev,
-   const struct hdmi_avi_infoframe *avi)
-{
-   struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
-
-   hdmi->cfg.infoframe = *avi;
-   return 0;
-}
-
 static int hdmi_set_hdmi_mode(struct omap_dss_device *dssdev,
bool hdmi_mode)
 {
@@ -552,7 +543,6 @@ static const struct omapdss_hdmi_ops hdmi_ops = {
.get_timings= hdmi_display_get_timings,
 
.read_edid  = hdmi_read_edid,
-   .set_infoframe  = hdmi_set_infoframe,
.set_hdmi_mode  = hdmi_set_hdmi_mode,
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 

[PATCH/RFC 09/60] drm/omap: dss: Remove DSS encoders get_timings operation

2018-03-06 Thread Laurent Pinchart
The get_timings operation from DSS encoders (not to be confused with the
identically named operation in omap_dss_driver) is never called. Remove
it.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c| 11 ---
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c|  9 -
 drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c |  9 -
 drivers/gpu/drm/omapdrm/dss/dpi.c| 13 -
 drivers/gpu/drm/omapdrm/dss/hdmi4.c  |  9 -
 drivers/gpu/drm/omapdrm/dss/hdmi5.c  |  9 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h| 10 --
 drivers/gpu/drm/omapdrm/dss/sdi.c|  9 -
 drivers/gpu/drm/omapdrm/dss/venc.c   | 13 -
 9 files changed, 92 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index afee1b8b457a..27d63a14efe3 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -148,16 +148,6 @@ static void opa362_set_timings(struct omap_dss_device 
*dssdev,
in->ops.atv->set_timings(in, vm);
 }
 
-static void opa362_get_timings(struct omap_dss_device *dssdev,
-  struct videomode *vm)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-
-   dev_dbg(dssdev->dev, "get_timings\n");
-
-   *vm = ddata->vm;
-}
-
 static int opa362_check_timings(struct omap_dss_device *dssdev,
struct videomode *vm)
 {
@@ -178,7 +168,6 @@ static const struct omapdss_atv_ops opa362_atv_ops = {
 
.check_timings  = opa362_check_timings,
.set_timings= opa362_set_timings,
-   .get_timings= opa362_get_timings,
 };
 
 static int opa362_probe(struct platform_device *pdev)
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index ed7ae384c3ed..566c63a3ad59 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -142,14 +142,6 @@ static void tfp410_set_timings(struct omap_dss_device 
*dssdev,
in->ops.dpi->set_timings(in, vm);
 }
 
-static void tfp410_get_timings(struct omap_dss_device *dssdev,
-  struct videomode *vm)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-
-   *vm = ddata->vm;
-}
-
 static int tfp410_check_timings(struct omap_dss_device *dssdev,
struct videomode *vm)
 {
@@ -170,7 +162,6 @@ static const struct omapdss_dvi_ops tfp410_dvi_ops = {
 
.check_timings  = tfp410_check_timings,
.set_timings= tfp410_set_timings,
-   .get_timings= tfp410_get_timings,
 };
 
 static int tfp410_probe_of(struct platform_device *pdev)
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
index efe608ce0f2a..ef2821243d67 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
@@ -136,14 +136,6 @@ static void tpd_set_timings(struct omap_dss_device *dssdev,
in->ops.hdmi->set_timings(in, vm);
 }
 
-static void tpd_get_timings(struct omap_dss_device *dssdev,
-   struct videomode *vm)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-
-   *vm = ddata->vm;
-}
-
 static int tpd_check_timings(struct omap_dss_device *dssdev,
 struct videomode *vm)
 {
@@ -240,7 +232,6 @@ static const struct omapdss_hdmi_ops tpd_hdmi_ops = {
 
.check_timings  = tpd_check_timings,
.set_timings= tpd_set_timings,
-   .get_timings= tpd_get_timings,
 
.read_edid  = tpd_read_edid,
.detect = tpd_detect,
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index fb1c27f69e3a..8c755f3fd359 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -490,18 +490,6 @@ static void dpi_set_timings(struct omap_dss_device *dssdev,
mutex_unlock(>lock);
 }
 
-static void dpi_get_timings(struct omap_dss_device *dssdev,
-   struct videomode *vm)
-{
-   struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
-
-   mutex_lock(>lock);
-
-   *vm = dpi->vm;
-
-   mutex_unlock(>lock);
-}
-
 static int dpi_check_timings(struct omap_dss_device *dssdev,
 struct videomode *vm)
 {
@@ -701,7 +689,6 @@ static const struct omapdss_dpi_ops dpi_ops = {
 
.check_timings = dpi_check_timings,
.set_timings = dpi_set_timings,
-   .get_timings = dpi_get_timings,
 };
 
 static void dpi_init_output_port(struct dpi_data *dpi, struct 

[PATCH/RFC 06/60] drm/omap: dss: Move platform_device_register from core.c to dss.c probe

2018-03-06 Thread Laurent Pinchart
From: Jyri Sarha 

Register the omapdrm device when we know that dss device probe going
to succeed. This avoids DSS6 and DSS2 omapdrm device registration from
colliding with each other.

Signed-off-by: Jyri Sarha 
Signed-off-by: Laurent Pinchart 
---
Changes since v0:

- Store the OMAP DRM platform device pointer in struct dss_device
- Register the OMAP DRM platform device at the very end of dss_bind()
---
 drivers/gpu/drm/omapdrm/dss/core.c | 26 ++
 drivers/gpu/drm/omapdrm/dss/dss.c  | 13 +
 drivers/gpu/drm/omapdrm/dss/dss.h  |  2 ++
 3 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/core.c 
b/drivers/gpu/drm/omapdrm/dss/core.c
index acef7ece5783..6c9f667f9982 100644
--- a/drivers/gpu/drm/omapdrm/dss/core.c
+++ b/drivers/gpu/drm/omapdrm/dss/core.c
@@ -45,36 +45,14 @@ static struct platform_driver * const omap_dss_drivers[] = {
 #endif
 };
 
-static struct platform_device *omap_drm_device;
-
 static int __init omap_dss_init(void)
 {
-   int r;
-
-   r = platform_register_drivers(omap_dss_drivers,
- ARRAY_SIZE(omap_dss_drivers));
-   if (r)
-   goto err_reg;
-
-   omap_drm_device = platform_device_register_simple("omapdrm", 0, NULL, 
0);
-   if (IS_ERR(omap_drm_device)) {
-   r = PTR_ERR(omap_drm_device);
-   goto err_reg;
-   }
-
-   return 0;
-
-err_reg:
-   platform_unregister_drivers(omap_dss_drivers,
-   ARRAY_SIZE(omap_dss_drivers));
-
-   return r;
+   return platform_register_drivers(omap_dss_drivers,
+ARRAY_SIZE(omap_dss_drivers));
 }
 
 static void __exit omap_dss_exit(void)
 {
-   platform_device_unregister(omap_drm_device);
-
platform_unregister_drivers(omap_dss_drivers,
ARRAY_SIZE(omap_dss_drivers));
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index f2e32ebda316..5f7789cf43c7 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1317,6 +1317,7 @@ static const struct soc_device_attribute 
dss_soc_devices[] = {
 static int dss_bind(struct device *dev)
 {
struct dss_device *dss = dev_get_drvdata(dev);
+   struct platform_device *drm_pdev;
int r;
 
r = component_bind_all(dev, NULL);
@@ -1327,11 +1328,23 @@ static int dss_bind(struct device *dev)
 
omapdss_set_dss(dss);
 
+   drm_pdev = platform_device_register_simple("omapdrm", 0, NULL, 0);
+   if (IS_ERR(drm_pdev)) {
+   component_unbind_all(dev, NULL);
+   return PTR_ERR(drm_pdev);
+   }
+
+   dss->drm_pdev = drm_pdev;
+
return 0;
 }
 
 static void dss_unbind(struct device *dev)
 {
+   struct dss_device *dss = dev_get_drvdata(dev);
+
+   platform_device_unregister(dss->drm_pdev);
+
omapdss_set_dss(NULL);
 
component_unbind_all(dev, NULL);
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index c601ed9a09c2..73f5e8fc18cf 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -235,6 +235,8 @@ struct dss_device {
struct regmap   *syscon_pll_ctrl;
u32 syscon_pll_ctrl_offset;
 
+   struct platform_device *drm_pdev;
+
struct clk  *parent_clk;
struct clk  *dss_clk;
unsigned long   dss_clk_rate;
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 03/60] drm/omap: Do dss_device (display) ordering in omap_drv.c

2018-03-06 Thread Laurent Pinchart
From: Peter Ujfalusi 

Sort the dssdev array based on DT aliases.

With this change we can remove the panel ordering from dss/display.c and
have all sorting related to dssdevs in one place.

Signed-off-by: Peter Ujfalusi 
Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Signed-off-by: Laurent Pinchart 
---
Changes since v0:

- Make alias_id unsigned
---
 drivers/gpu/drm/omapdrm/dss/display.c |  2 ++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  1 +
 drivers/gpu/drm/omapdrm/omap_drv.c| 18 ++
 3 files changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/display.c 
b/drivers/gpu/drm/omapdrm/dss/display.c
index 424143128cd4..3ef99f344bd3 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -52,6 +52,8 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
if (id < 0)
id = disp_num_counter++;
 
+   dssdev->alias_id = id;
+
snprintf(dssdev->alias, sizeof(dssdev->alias), "display%d", id);
 
/* Use 'label' property for name, if it exists */
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 14d74adb13fb..eae105b0b961 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -467,6 +467,7 @@ struct omap_dss_device {
 
/* alias in the form of "display%d" */
char alias[16];
+   unsigned int alias_id;
 
enum omap_display_type type;
enum omap_display_type output_type;
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 37ec9cd6c0ca..a9e02a58f76c 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -15,6 +15,8 @@
  * this program.  If not, see .
  */
 
+#include 
+#include 
 #include 
 
 #include 
@@ -165,6 +167,18 @@ static void omap_disconnect_dssdevs(struct drm_device 
*ddev)
priv->num_dssdevs = 0;
 }
 
+static int omap_compare_dssdevs(const void *a, const void *b)
+{
+   const struct omap_dss_device *dssdev1 = *(struct omap_dss_device **)a;
+   const struct omap_dss_device *dssdev2 = *(struct omap_dss_device **)b;
+
+   if (dssdev1->alias_id > dssdev2->alias_id)
+   return 1;
+   else if (dssdev1->alias_id < dssdev2->alias_id)
+   return -1;
+   return 0;
+}
+
 static int omap_connect_dssdevs(struct drm_device *ddev)
 {
struct omap_drm_private *priv = ddev->dev_private;
@@ -193,6 +207,10 @@ static int omap_connect_dssdevs(struct drm_device *ddev)
}
}
 
+   /* Sort the list by DT aliases */
+   sort(priv->dssdevs, priv->num_dssdevs, sizeof(priv->dssdevs[0]),
+omap_compare_dssdevs, NULL);
+
return 0;
 
 cleanup:
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 05/60] drm/omap: dss: Gather OMAP DSS components at probe time

2018-03-06 Thread Laurent Pinchart
The omapdss_gather_components() function walks the OF graph to create a
list of all components part of the display device. There's no need to
delay this operation until DSS bind time as we have all the information
we need at probe time.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 4a08bd1fc522..f2e32ebda316 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1325,7 +1325,6 @@ static int dss_bind(struct device *dev)
 
pm_set_vt_switch(0);
 
-   omapdss_gather_components(dev);
omapdss_set_dss(dss);
 
return 0;
@@ -1476,6 +1475,8 @@ static int dss_probe(struct platform_device *pdev)
   dss);
 
/* Add all the child devices as components. */
+   omapdss_gather_components(>dev);
+
device_for_each_child(>dev, , dss_add_child_component);
 
r = component_master_add_with_match(>dev, _component_ops, 
match);
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 00/60] omapdrm: Reverse direction of DSS device (dis)connect operations

2018-03-06 Thread Laurent Pinchart
Hello,

This patch series is a first step towards moving the omapdrm driver away from
the custom bridge and panel drivers to drm_bridge and drm_panel.

The main blocker to transition to drm_bridge and drm_panel is the direction of
the bridge operations. While the omapdrm driver manages its components from
sink to source (panel to DSS output), the drm_bridge API is manages bridges in
the source to sink direction. This makes the two models incompatible, and
requires reversing the direction of operations inside omapdrm.

Don't rejoice too fast, we're still far from a complete transition, but this
first step paves the way by reworking the driver's internals to make source to
sink order possible. It then transitions the connect and disconnect operations
(the omapdrm equivalent of the drm_bridge attach and detach operations) to the
new direction.

I've sent the patches as an RFC as I might not be aware of all the
consequences of the numerous changes to the driver's internals, even if I took
care to analyze the code flows to the best of my abilities.

The series contains patches previously posted by Jyri and Peter that I have
found helpful. Please see the individual patches for changes compared to the
original versions (trivial conflict resolutions caused by a rebase are not
mentioned).

The patches are based on top of a merge between Tomi's omapdrm-next branch and
the drm-misc/drm-misc-next branch for the "drm: fix drm_get_max_iomem type
mismatch" compilation fix. They can be found at

git://linuxtv.org/pinchartl/media.git omapdrm/bridge

The series has been tested on a Pandaboard with the HDMI and DVI outputs. All
patches have been at least compile-tested individually. I'll now go through
the process of making sure each of them gets tested on hardware as well.

Jyri Sarha (1):
  drm/omap: dss: Move platform_device_register from core.c to dss.c
probe

Laurent Pinchart (55):
  drm/omap: dss: Gather OMAP DSS components at probe time
  drm/omap: dss: Remove omapdss_hdmi_ops set_infoframe operation
  drm/omap: dss: Remove omapdss_atv_ops get_wss and set_wss operations
  drm/omap: dss: Remove DSS encoders get_timings operation
  drm/omap: dss: Remove unused omapdss_default_get_timings()
  drm/omap: dss: Constify omap_dss_driver operations structure
  drm/omap: displays: Remove videomode from omap_dss_device structure
  drm/omap: dss: Remove omap_dss_device panel fields
  drm/omap: dss: Rename omap_dss_device list field to output_list
  drm/omap: dss: Create global list of all omap_dss_device instances
  drm/omap: dss: Create and use omapdss_device_is_registered()
  drm/omap: dss: Rework output lookup by port node
  drm/omap: dss: Allow looking up any device by port
  drm/omap: dss: Move common device operations to common structure
  drm/omap: dss: Add functions to connect and disconnect devices
  drm/omap: dss: Move debug message and checks to connection handlers
  drm/omap: dss: Move src and dst check and set to connection handlers
  drm/omap: displays: Remove input omap_dss_device from panel data
  drm/omap: dsi: Simplify debugfs implementation
  drm/omap: Move DSI debugfs clocks dump to dsi%u_clks files
  drm/omap: dss: Remove output devices list
  drm/omap: dss: Rename for_each_dss_dev macro to for_each_dss_display
  drm/omap: dss: Make omap_dss_get_next_device() more generic
  drm/omap: dss: Split omapdss_register_display()
  drm/omap: dss: Remove panel devices list
  drm/omap: dss: Move and rename omap_dss_(get|put)_device()
  drm/omap: dss: Store dss_device pointer in omap_dss_device
  drm/omap: dss: Move DSS mgr ops and private data to dss_device
  drm/omap: dss: Modify omapdss_find_output_from_display() to return
channel
  drm/omap: dss: Replace omap_dss_device port number with bitmask
  drm/omap: dss: Extend omapdss_of_find_source_for_first_ep() to sinks
  drm/omap: displays: Don't cast dssdev to panel data unnecessarily
  drm/omap: dss: Cleanup error paths in output init functions
  drm/omap: dss: dsi: Move initialization code from bind to probe
  drm/omap: dss: hdmi4: Move initialization code from bind to probe
  drm/omap: dss: hdmi5: Move initialization code from bind to probe
  drm/omap: dss: venc: Move initialization code from bind to probe
  drm/omap: dss: Acquire next dssdev at probe time
  drm/omap: dss: Add for_each_dss_output() macro
  drm/omap: dss: Add function to retrieve display for an output
  drm/omap: dss: Remove duplicated parameter to dss_mgr_(dis)connect()
  drm/omap: dss: Get regulators at probe time
  drm/omap: Remove unneeded variable assignments in omap_modeset_init
  drm/omap: Create all planes before CRTCs
  drm/omap: Group CRTC, encoder, connector and dssdev in a structure
  drm/omap: Reverse direction of DSS device (dis)connect operations
  drm/omap: dss: Move connection checks to omapdss_device_(dis)connect
  drm/omap: dss: Move display type validation to initialization time
  drm/omap: dss: Merge two disconnection helpers
  drm/omap: Pass pipe pointer to 

[PATCH/RFC 01/60] drm/omap: Allocate drm_device earlier and unref it as last step

2018-03-06 Thread Laurent Pinchart
From: Peter Ujfalusi 

If we allocate the drm_device earlier we can just return the error code
without the need to use goto.
Do the unref of the drm_device as a last step when cleaning up. This will
make the drm_device available longer for us and makes sure that we only
free up the memory when all other cleanups have been already done.

Signed-off-by: Peter Ujfalusi 
Reviewed-by: Laurent Pinchart 
Signed-off-by: Tomi Valkeinen 
Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 29 +
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 3632854c2b91..5ef43948b342 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -522,6 +522,14 @@ static int omapdrm_init(struct omap_drm_private *priv, 
struct device *dev)
 
DBG("%s", dev_name(dev));
 
+   /* Allocate and initialize the DRM device. */
+   ddev = drm_dev_alloc(_drm_driver, dev);
+   if (IS_ERR(ddev))
+   return PTR_ERR(ddev);
+
+   priv->ddev = ddev;
+   ddev->dev_private = priv;
+
priv->dev = dev;
priv->dss = omapdss_get_dss();
priv->dispc = dispc_get_dispc(priv->dss);
@@ -540,16 +548,6 @@ static int omapdrm_init(struct omap_drm_private *priv, 
struct device *dev)
spin_lock_init(>list_lock);
INIT_LIST_HEAD(>obj_list);
 
-   /* Allocate and initialize the DRM device. */
-   ddev = drm_dev_alloc(_drm_driver, priv->dev);
-   if (IS_ERR(ddev)) {
-   ret = PTR_ERR(ddev);
-   goto err_destroy_wq;
-   }
-
-   priv->ddev = ddev;
-   ddev->dev_private = priv;
-
/* Get memory bandwidth limits */
if (priv->dispc_ops->get_memory_bandwidth_limit)
priv->max_bandwidth =
@@ -560,7 +558,7 @@ static int omapdrm_init(struct omap_drm_private *priv, 
struct device *dev)
ret = omap_modeset_init(ddev);
if (ret) {
dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret);
-   goto err_free_drm_dev;
+   goto err_gem_deinit;
}
 
/* Initialize vblank handling, start with all CRTCs disabled. */
@@ -596,14 +594,13 @@ static int omapdrm_init(struct omap_drm_private *priv, 
struct device *dev)
 err_cleanup_modeset:
drm_mode_config_cleanup(ddev);
omap_drm_irq_uninstall(ddev);
-err_free_drm_dev:
+err_gem_deinit:
omap_gem_deinit(ddev);
-   drm_dev_unref(ddev);
-err_destroy_wq:
destroy_workqueue(priv->wq);
omap_disconnect_dssdevs();
 err_crtc_uninit:
omap_crtc_pre_uninit();
+   drm_dev_unref(ddev);
return ret;
 }
 
@@ -627,12 +624,12 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)
omap_drm_irq_uninstall(ddev);
omap_gem_deinit(ddev);
 
-   drm_dev_unref(ddev);
-
destroy_workqueue(priv->wq);
 
omap_disconnect_dssdevs();
omap_crtc_pre_uninit();
+
+   drm_dev_unref(ddev);
 }
 
 static int pdev_probe(struct platform_device *pdev)
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 04/60] drm/omap: dss: Remove display ordering from dss/display.c

2018-03-06 Thread Laurent Pinchart
From: Peter Ujfalusi 

As ordering of the dss_devices based on DT aliases is now implemented in
omap_drm.c, there is no need to do the ordering in dss/display.c
anymore.

At the same time remove the alias member of the omap_dss_device struct
since it is no longer needed. The only place it was used is in the
omapdss_register_display() function.

Signed-off-by: Peter Ujfalusi 
Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Signed-off-by: Laurent Pinchart 
---
Changes since v0:

- Use %u to format display ID
---
 drivers/gpu/drm/omapdrm/dss/display.c | 15 +++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  2 --
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/display.c 
b/drivers/gpu/drm/omapdrm/dss/display.c
index 3ef99f344bd3..25c3be86d7f4 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -41,7 +41,6 @@ static int disp_num_counter;
 int omapdss_register_display(struct omap_dss_device *dssdev)
 {
struct omap_dss_driver *drv = dssdev->driver;
-   struct list_head *cur;
int id;
 
/*
@@ -54,26 +53,18 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
 
dssdev->alias_id = id;
 
-   snprintf(dssdev->alias, sizeof(dssdev->alias), "display%d", id);
-
/* Use 'label' property for name, if it exists */
of_property_read_string(dssdev->dev->of_node, "label", >name);
 
if (dssdev->name == NULL)
-   dssdev->name = dssdev->alias;
+   dssdev->name = devm_kasprintf(dssdev->dev, GFP_KERNEL,
+ "display%u", id);
 
if (drv && drv->get_timings == NULL)
drv->get_timings = omapdss_default_get_timings;
 
mutex_lock(_list_mutex);
-   list_for_each(cur, _list) {
-   struct omap_dss_device *ldev = list_entry(cur,
-struct omap_dss_device,
-panel_list);
-   if (strcmp(ldev->alias, dssdev->alias) > 0)
-   break;
-   }
-   list_add_tail(>panel_list, cur);
+   list_add_tail(>panel_list, _list);
mutex_unlock(_list_mutex);
return 0;
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index eae105b0b961..8d530057a4b9 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -465,8 +465,6 @@ struct omap_dss_device {
 
struct list_head panel_list;
 
-   /* alias in the form of "display%d" */
-   char alias[16];
unsigned int alias_id;
 
enum omap_display_type type;
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH/RFC 02/60] drm/omap: Manage the usable omap_dss_device list within omap_drm_private

2018-03-06 Thread Laurent Pinchart
From: Peter Ujfalusi 

Instead of reaching back to DSS to iterate through the dss_devices every
time, use an internal array where we store the available and usable
dss_devices.

At the same time remove the omapdss_device_is_connected() check from
omap_modeset_init() as it became irrelevant: We are not adding dssdevs
if their connect failed.

Signed-off-by: Peter Ujfalusi 
Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Signed-off-by: Laurent Pinchart 
---
Changes since v0:

- Make loop counter unsigned
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 94 --
 drivers/gpu/drm/omapdrm/omap_drv.h |  3 ++
 2 files changed, 62 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 5ef43948b342..37ec9cd6c0ca 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -149,18 +149,27 @@ static int get_connector_type(struct omap_dss_device 
*dssdev)
}
 }
 
-static void omap_disconnect_dssdevs(void)
+static void omap_disconnect_dssdevs(struct drm_device *ddev)
 {
-   struct omap_dss_device *dssdev = NULL;
+   struct omap_drm_private *priv = ddev->dev_private;
+   unsigned int i;
+
+   for (i = 0; i < priv->num_dssdevs; i++) {
+   struct omap_dss_device *dssdev = priv->dssdevs[i];
 
-   for_each_dss_dev(dssdev)
dssdev->driver->disconnect(dssdev);
+   priv->dssdevs[i] = NULL;
+   omap_dss_put_device(dssdev);
+   }
+
+   priv->num_dssdevs = 0;
 }
 
-static int omap_connect_dssdevs(void)
+static int omap_connect_dssdevs(struct drm_device *ddev)
 {
-   int r;
+   struct omap_drm_private *priv = ddev->dev_private;
struct omap_dss_device *dssdev = NULL;
+   int r;
 
if (!omapdss_stack_is_ready())
return -EPROBE_DEFER;
@@ -173,6 +182,14 @@ static int omap_connect_dssdevs(void)
} else if (r) {
dev_warn(dssdev->dev, "could not connect display: %s\n",
dssdev->name);
+   } else {
+   omap_dss_get_device(dssdev);
+   priv->dssdevs[priv->num_dssdevs++] = dssdev;
+   if (priv->num_dssdevs == ARRAY_SIZE(priv->dssdevs)) {
+   /* To balance the 'for_each_dss_dev' loop */
+   omap_dss_put_device(dssdev);
+   break;
+   }
}
}
 
@@ -183,7 +200,7 @@ static int omap_connect_dssdevs(void)
 * if we are deferring probe, we disconnect the devices we previously
 * connected
 */
-   omap_disconnect_dssdevs();
+   omap_disconnect_dssdevs(ddev);
 
return r;
 }
@@ -208,6 +225,7 @@ static int omap_modeset_init(struct drm_device *dev)
int num_ovls = priv->dispc_ops->get_num_ovls(priv->dispc);
int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
int num_crtcs, crtc_idx, plane_idx;
+   unsigned int i;
int ret;
u32 plane_crtc_mask;
 
@@ -225,11 +243,7 @@ static int omap_modeset_init(struct drm_device *dev)
 * configuration does not match the expectations or exceeds
 * the available resources, the configuration is rejected.
 */
-   num_crtcs = 0;
-   for_each_dss_dev(dssdev)
-   if (omapdss_device_is_connected(dssdev))
-   num_crtcs++;
-
+   num_crtcs = priv->num_dssdevs;
if (num_crtcs > num_mgrs || num_crtcs > num_ovls ||
num_crtcs > ARRAY_SIZE(priv->crtcs) ||
num_crtcs > ARRAY_SIZE(priv->planes) ||
@@ -247,15 +261,13 @@ static int omap_modeset_init(struct drm_device *dev)
 
crtc_idx = 0;
plane_idx = 0;
-   for_each_dss_dev(dssdev) {
+   for (i = 0; i < priv->num_dssdevs; i++) {
+   struct omap_dss_device *dssdev = priv->dssdevs[i];
struct drm_connector *connector;
struct drm_encoder *encoder;
struct drm_plane *plane;
struct drm_crtc *crtc;
 
-   if (!omapdss_device_is_connected(dssdev))
-   continue;
-
encoder = omap_encoder_init(dev, dssdev);
if (!encoder)
return -ENOMEM;
@@ -332,11 +344,14 @@ static int omap_modeset_init(struct drm_device *dev)
 /*
  * Enable the HPD in external components if supported
  */
-static void omap_modeset_enable_external_hpd(void)
+static void omap_modeset_enable_external_hpd(struct drm_device *ddev)
 {
-   struct omap_dss_device *dssdev = NULL;
+   struct omap_drm_private *priv = ddev->dev_private;
+   int i;
+
+   for (i = 0; i < priv->num_dssdevs; i++) {
+

Re: [PATCH 2/3] drm/vc4: Check if plane requires background fill

2018-03-06 Thread Eric Anholt
Ville Syrjälä  writes:

> On Tue, Mar 06, 2018 at 02:48:38AM +0100, Stefan Schake wrote:
>> Considering a single plane only, we have to enable background color
>> when the plane has an alpha format and could be blending from the
>> background or when it doesn't cover the entire screen.
>> 
>> Signed-off-by: Stefan Schake 
>> ---
>>  drivers/gpu/drm/vc4/vc4_drv.h   |  6 ++
>>  drivers/gpu/drm/vc4/vc4_plane.c | 15 ++-
>>  2 files changed, 20 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
>> index fefa166..7cc6390 100644
>> --- a/drivers/gpu/drm/vc4/vc4_drv.h
>> +++ b/drivers/gpu/drm/vc4/vc4_drv.h
>> @@ -302,6 +302,12 @@ struct vc4_hvs {
>>  
>>  struct vc4_plane {
>>  struct drm_plane base;
>> +
>> +/* Set when the plane has per-pixel alpha content or does not cover
>> + * the entire screen. This is a hint to the CRTC that it might need
>> + * to enable background color fill.
>> + */
>> +bool needs_bg_fill;
>
> Looks to me like that should really be a bitmask (or something similar)
> in the crtc state.

Why?

In particular, VC4 really doesn't have a fixed number of planes, and the
fact that we're exposing just a handful so far is probably a bug.


signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 5/6] drm/i915: Introduce 'priority offset' for GPU contexts (v2)

2018-03-06 Thread Matt Roper
There are cases where a system integrator may wish to raise/lower the
priority of GPU workloads being submitted by specific OS process(es),
independently of how the software self-classifies its own priority.
Exposing "priority offset" as an i915-specific cgroup parameter will
enable such system-level configuration.

Normally GPU contexts start with a priority value of 0
(I915_CONTEXT_DEFAULT_PRIORITY) and then may be adjusted up/down from
there via other mechanisms.  We'd like to provide a system-level input
to the priority decision that will be taken into consideration, even
when userspace later attempts to set an absolute priority value via
I915_CONTEXT_PARAM_PRIORITY.  The priority offset introduced here
provides a base value that will always be added to (or subtracted from)
the software's self-assigned priority value.

This patch makes priority offset a cgroup-specific value; contexts will
be created with a priority offset based on the cgroup membership of the
process creating the context at the time the context is created.  Note
that priority offset is assigned at context creation time; migrating a
process to a different cgroup or changing the offset associated with a
cgroup will only affect new context creation and will not alter the
behavior of existing contexts previously created by the process.

v2:
 - Rebase onto new cgroup_priv API
 - Use current instead of drm_file->pid to determine which process to
   lookup priority for. (Chris)
 - Don't forget to subtract priority offset in context_getparam ioctl to
   make it match setparam behavior. (Chris)

Signed-off-by: Matt Roper 
---
 drivers/gpu/drm/i915/i915_cgroup.c  | 47 +
 drivers/gpu/drm/i915/i915_drv.h | 15 ++-
 drivers/gpu/drm/i915/i915_gem_context.c |  7 ++---
 drivers/gpu/drm/i915/i915_gem_context.h |  9 +++
 include/uapi/drm/i915_drm.h |  1 +
 5 files changed, 69 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_cgroup.c 
b/drivers/gpu/drm/i915/i915_cgroup.c
index 4a46cb167f53..6a28b1a23971 100644
--- a/drivers/gpu/drm/i915/i915_cgroup.c
+++ b/drivers/gpu/drm/i915/i915_cgroup.c
@@ -13,6 +13,8 @@ struct i915_cgroup_data {
struct cgroup_priv base;
 
struct list_head node;
+
+   int priority_offset;
 };
 
 static inline struct i915_cgroup_data *
@@ -117,8 +119,10 @@ i915_cgroup_setparam_ioctl(struct drm_device *dev,
   void *data,
   struct drm_file *file)
 {
+   struct drm_i915_private *dev_priv = to_i915(dev);
struct drm_i915_cgroup_param *req = data;
struct cgroup *cgrp;
+   struct i915_cgroup_data *cgrpdata;
int ret;
 
/* We don't actually support any flags yet. */
@@ -154,7 +158,18 @@ i915_cgroup_setparam_ioctl(struct drm_device *dev,
if (ret)
goto out;
 
+   cgrpdata = get_or_create_cgroup_data(dev_priv, cgrp);
+   if (IS_ERR(cgrpdata)) {
+   ret = PTR_ERR(cgrpdata);
+   goto out;
+   }
+
switch (req->param) {
+   case I915_CGROUP_PARAM_PRIORITY_OFFSET:
+   DRM_DEBUG_DRIVER("Setting cgroup priority offset to %lld\n",
+req->value);
+   cgrpdata->priority_offset = req->value;
+   break;
default:
DRM_DEBUG_DRIVER("Invalid cgroup parameter %lld\n", req->param);
ret = -EINVAL;
@@ -165,3 +180,35 @@ i915_cgroup_setparam_ioctl(struct drm_device *dev,
 
return ret;
 }
+
+/**
+ * i915_cgroup_get_prio_offset() - get prio offset for current proc's cgroup
+ * @dev_priv: drm device
+ * @file_priv: file handle for calling process
+ *
+ * RETURNS:
+ * Priority offset associated with the calling process' cgroup in the default
+ * (v2) hierarchy, otherwise 0 if no explicit priority has been assigned.
+ */
+int
+i915_cgroup_get_current_prio_offset(struct drm_i915_private *dev_priv)
+{
+   struct cgroup *cgrp;
+   struct cgroup_priv *cgrpdata;
+   int offset = 0;
+
+   cgrp = task_get_dfl_cgroup(current);
+   if (WARN_ON(!cgrp))
+   return 0;
+
+   mutex_lock(>privdata_mutex);
+
+   cgrpdata = cgroup_priv_lookup(cgrp, dev_priv);
+   if (cgrpdata)
+  offset = cgrp_to_i915(cgrpdata)->priority_offset;
+
+   mutex_unlock(>privdata_mutex);
+   cgroup_put(cgrp);
+
+   return offset;
+}
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 7c38142ee009..51b80926d20c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2947,18 +2947,19 @@ void i915_cgroup_init(struct drm_i915_private 
*dev_priv);
 int i915_cgroup_setparam_ioctl(struct drm_device *dev, void *data,
   struct drm_file *file);
 void i915_cgroup_shutdown(struct drm_i915_private *dev_priv);
+int i915_cgroup_get_current_prio_offset(struct 

[PATCH v3 6/6] drm/i915: Add context priority & priority offset to debugfs (v2)

2018-03-06 Thread Matt Roper
Update i915_context_status to include priority information.

v2:
 - Clarify that the offset is based on cgroup (Chris)

Signed-off-by: Matt Roper 
---
 drivers/gpu/drm/i915/i915_debugfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index e838c765b251..eb1cb9a9f5b0 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -1960,6 +1960,9 @@ static int i915_context_status(struct seq_file *m, void 
*unused)
seq_putc(m, ctx->remap_slice ? 'R' : 'r');
seq_putc(m, '\n');
 
+   seq_printf(m, "Priority %d (cgroup offset = %d)\n",
+  ctx->priority, ctx->priority_offset);
+
for_each_engine(engine, dev_priv, id) {
struct intel_context *ce = >engine[engine->id];
 
-- 
2.14.3

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 1/6] cgroup: Allow registration and lookup of cgroup private data

2018-03-06 Thread Matt Roper
There are cases where other parts of the kernel may wish to store data
associated with individual cgroups without building a full cgroup
controller.  Let's add interfaces to allow them to register and lookup
this private data for individual cgroups.

A kernel system (e.g., a driver) that wishes to register private data
for a cgroup will do so by subclassing the 'struct cgroup_priv'
structure to describe the necessary data to store.  Before registering a
private data structure to a cgroup, the caller should fill in the 'key'
and 'free' fields of the base cgroup_priv structure.

 * 'key' should be a unique void* that will act as a key for future
   privdata lookups/removals.  Note that this allows drivers to store
   per-device private data for a cgroup by using a device pointer as a key.

 * 'free' should be a function pointer to a function that may be used
   to destroy the private data.  This function will be called
   automatically if the underlying cgroup is destroyed.

Cc: Tejun Heo 
Cc: cgro...@vger.kernel.org
Signed-off-by: Matt Roper 
---
 include/linux/cgroup-defs.h | 38 ++
 include/linux/cgroup.h  | 78 +
 kernel/cgroup/cgroup.c  | 14 
 3 files changed, 130 insertions(+)

diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index 9f242b876fde..17c679a7b5de 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -8,6 +8,7 @@
 #ifndef _LINUX_CGROUP_DEFS_H
 #define _LINUX_CGROUP_DEFS_H
 
+#include 
 #include 
 #include 
 #include 
@@ -307,6 +308,36 @@ struct cgroup_stat {
struct prev_cputime prev_cputime;
 };
 
+/*
+ * Private data associated with a cgroup by an indpendent (non-controller) part
+ * of the kernel.  This is useful for things like drivers that may wish to 
track
+ * their own cgroup-specific data.
+ *
+ * If an individual cgroup is destroyed, the cgroups framework will
+ * automatically free all associated private data.  If cgroup private data is
+ * registered by a kernel module, then it is the module's responsibility to
+ * manually free its own private data upon unload.
+ */
+struct cgroup_priv {
+   /* cgroup this private data is associated with */
+   struct cgroup *cgroup;
+
+   /*
+* Lookup key that defines the in-kernel consumer of this private
+* data.
+*/
+   const void *key;
+
+   /*
+* Function to release private data.  This will be automatically called
+* if/when the cgroup is destroyed.
+*/
+   void (*free)(struct cgroup_priv *priv);
+
+   /* Hashlist node in cgroup's privdata hashtable */
+   struct hlist_node hnode;
+};
+
 struct cgroup {
/* self css with NULL ->ss, points back to this cgroup */
struct cgroup_subsys_state self;
@@ -427,6 +458,13 @@ struct cgroup {
/* used to store eBPF programs */
struct cgroup_bpf bpf;
 
+   /*
+* cgroup private data registered by other non-controller parts of the
+* kernel
+*/
+   DECLARE_HASHTABLE(privdata, 4);
+   struct mutex privdata_mutex;
+
/* ids of the ancestors at each level including self */
int ancestor_ids[];
 };
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 473e0c0abb86..a3604b005417 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -833,4 +833,82 @@ static inline void put_cgroup_ns(struct cgroup_namespace 
*ns)
free_cgroup_ns(ns);
 }
 
+/**
+ * cgroup_priv_install - install new cgroup private data
+ * @key: Key uniquely identifying kernel owner of private data
+ *
+ * Allows non-controller kernel subsystems to register their own private data
+ * associated with a cgroup.  This will often be used by drivers which wish to
+ * track their own per-cgroup data without building a full cgroup controller.
+ *
+ * Callers should ensure that no existing private data exists for the given key
+ * before adding new private data.  If two sets of private data are registered
+ * with the same key, it is undefined which will be returned by future calls
+ * to cgroup_priv_lookup.
+ *
+ * Kernel modules that register private data with this function should take
+ * care to free their private data when unloaded to prevent leaks.
+ */
+static inline void
+cgroup_priv_install(struct cgroup *cgrp,
+   struct cgroup_priv *priv)
+{
+   WARN_ON(!mutex_is_locked(>privdata_mutex));
+   WARN_ON(!priv->key);
+   WARN_ON(!priv->free);
+   WARN_ON(priv->cgroup);
+
+   priv->cgroup = cgrp;
+   hash_add(cgrp->privdata, >hnode,
+(unsigned long)priv->key);
+}
+
+/**
+ * cgroup_priv_lookup - looks up cgroup private data
+ * @key: Key uniquely identifying owner of private data to lookup
+ *
+ * Looks up the private data associated with a key.
+ *
+ * Returns:
+ * Previously registered cgroup private data associated with 

[PATCH v3 3/6] cgroup: Introduce cgroup_permission()

2018-03-06 Thread Matt Roper
Non-controller kernel subsystems may base access restrictions for
cgroup-related syscalls/ioctls on a process' access to the cgroup.
Let's make it easy for other parts of the kernel to check these cgroup
permissions.

Cc: Tejun Heo 
Cc: cgro...@vger.kernel.org
Signed-off-by: Matt Roper 
---
 include/linux/cgroup.h |  1 +
 kernel/cgroup/cgroup.c | 42 ++
 2 files changed, 43 insertions(+)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index b1ea2064f247..dd1d1d9813e8 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -100,6 +100,7 @@ struct cgroup_subsys_state 
*css_tryget_online_from_dir(struct dentry *dentry,
 
 struct cgroup *cgroup_get_from_path(const char *path);
 struct cgroup *cgroup_get_from_fd(int fd);
+int cgroup_permission(int fd, int mask);
 
 int cgroup_attach_task_all(struct task_struct *from, struct task_struct *);
 int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from);
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 9e576dc8b566..52d68b226867 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -5781,6 +5781,48 @@ struct cgroup *cgroup_get_from_fd(int fd)
 }
 EXPORT_SYMBOL_GPL(cgroup_get_from_fd);
 
+/**
+ * cgroup_permission - check cgroup fd permissions
+ * @fd: fd obtained by open(cgroup)
+ * @mask: Right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC)
+ *
+ * Check for read/write/execute permissions on a cgroup.
+ */
+int cgroup_permission(int fd, int mask)
+{
+   struct file *f;
+   struct inode *inode;
+   struct cgroup_subsys_state *css;
+   int ret;
+
+   f = fget_raw(fd);
+   if (!f)
+   return -EBADF;
+
+   css = css_tryget_online_from_dir(f->f_path.dentry, NULL);
+   if (IS_ERR(css)) {
+   ret = PTR_ERR(css);
+   goto out_file;
+   }
+
+   inode = kernfs_get_inode(f->f_path.dentry->d_sb, css->cgroup->kn);
+   if (!inode) {
+   ret = -ENOMEM;
+   goto out_cgroup;
+   }
+
+   ret = inode_permission(inode, mask);
+   iput(inode);
+
+out_cgroup:
+   cgroup_put(css->cgroup);
+out_file:
+   fput(f);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(cgroup_permission);
+
 /*
  * sock->sk_cgrp_data handling.  For more info, see sock_cgroup_data
  * definition in cgroup-defs.h.
-- 
2.14.3

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 4/6] drm/i915: cgroup integration (v2)

2018-03-06 Thread Matt Roper
Introduce a new DRM_IOCTL_I915_CGROUP_SETPARAM ioctl that will allow
userspace to set i915-specific parameters for individual cgroups.  i915
cgroup data will be registered and later looked up via the new
cgroup_priv infrastructure.

v2:
 - Large rebase/rewrite for new cgroup_priv interface

Signed-off-by: Matt Roper 
---
 drivers/gpu/drm/i915/Makefile  |   1 +
 drivers/gpu/drm/i915/i915_cgroup.c | 167 +
 drivers/gpu/drm/i915/i915_drv.c|   5 ++
 drivers/gpu/drm/i915/i915_drv.h|  24 ++
 include/uapi/drm/i915_drm.h|  12 +++
 5 files changed, 209 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/i915_cgroup.c

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 1bd9bc5b8c5c..5974e32834bf 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -48,6 +48,7 @@ i915-y := i915_drv.o \
 i915-$(CONFIG_COMPAT)   += i915_ioc32.o
 i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o
 i915-$(CONFIG_PERF_EVENTS) += i915_pmu.o
+i915-$(CONFIG_CGROUPS) += i915_cgroup.o
 
 # GEM code
 i915-y += i915_cmd_parser.o \
diff --git a/drivers/gpu/drm/i915/i915_cgroup.c 
b/drivers/gpu/drm/i915/i915_cgroup.c
new file mode 100644
index ..4a46cb167f53
--- /dev/null
+++ b/drivers/gpu/drm/i915/i915_cgroup.c
@@ -0,0 +1,167 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * i915_cgroup.c - Linux cgroups integration for i915
+ *
+ * Copyright (C) 2018 Intel Corporation
+ */
+
+#include 
+
+#include "i915_drv.h"
+
+struct i915_cgroup_data {
+   struct cgroup_priv base;
+
+   struct list_head node;
+};
+
+static inline struct i915_cgroup_data *
+cgrp_to_i915(struct cgroup_priv *priv)
+{
+   return container_of(priv, struct i915_cgroup_data, base);
+}
+
+static void
+i915_cgroup_free(struct cgroup_priv *priv)
+{
+   struct cgroup *cgrp = priv->cgroup;
+   struct i915_cgroup_data *ipriv;
+
+   WARN_ON(!mutex_is_locked(>privdata_mutex));
+
+   ipriv = cgrp_to_i915(priv);
+
+   /*
+* Remove private data from both cgroup's hashtable and i915's list.
+* If this function is being called as a result of cgroup removal
+* (as opposed to an i915 unload), it will have already been removed 
from
+* the hashtable, but the hash_del() call here is still safe.
+*/
+   hash_del(>hnode);
+   list_del(>node);
+
+   kfree(ipriv);
+}
+
+void
+i915_cgroup_init(struct drm_i915_private *dev_priv)
+{
+   INIT_LIST_HEAD(_priv->cgroup_list);
+}
+
+void
+i915_cgroup_shutdown(struct drm_i915_private *dev_priv)
+{
+   struct i915_cgroup_data *priv, *tmp;
+   struct cgroup *cgrp;
+
+   mutex_lock(_mutex);
+
+   list_for_each_entry_safe(priv, tmp, _priv->cgroup_list, node) {
+   cgrp = priv->base.cgroup;
+
+   mutex_lock(>privdata_mutex);
+   i915_cgroup_free(>base);
+   mutex_unlock(>privdata_mutex);
+   }
+
+   mutex_unlock(_mutex);
+}
+
+/*
+ * Return i915 cgroup private data, creating and registering it if one doesn't
+ * already exist for this cgroup.
+ */
+static struct i915_cgroup_data *
+get_or_create_cgroup_data(struct drm_i915_private *dev_priv,
+ struct cgroup *cgrp)
+{
+   struct cgroup_priv *priv;
+   struct i915_cgroup_data *ipriv;
+
+   mutex_lock(>privdata_mutex);
+
+   priv = cgroup_priv_lookup(cgrp, dev_priv);
+   if (priv) {
+   ipriv = cgrp_to_i915(priv);
+   } else {
+   ipriv = kzalloc(sizeof *ipriv, GFP_KERNEL);
+   if (!ipriv) {
+   ipriv = ERR_PTR(-ENOMEM);
+   goto out;
+   }
+
+   ipriv->base.key = dev_priv;
+   ipriv->base.free = i915_cgroup_free;
+   list_add(>node, _priv->cgroup_list);
+
+   cgroup_priv_install(cgrp, >base);
+   }
+
+out:
+   mutex_unlock(>privdata_mutex);
+
+   return ipriv;
+}
+
+/**
+ * i915_cgroup_setparam_ioctl - ioctl to alter i915 settings for a cgroup
+ * @dev: DRM device
+ * @data: data pointer for the ioctl
+ * @file_priv: DRM file handle for the ioctl call
+ *
+ * Allows i915-specific parameters to be set for a Linux cgroup.
+ */
+int
+i915_cgroup_setparam_ioctl(struct drm_device *dev,
+  void *data,
+  struct drm_file *file)
+{
+   struct drm_i915_cgroup_param *req = data;
+   struct cgroup *cgrp;
+   int ret;
+
+   /* We don't actually support any flags yet. */
+   if (req->flags) {
+   DRM_DEBUG_DRIVER("Invalid flags\n");
+   return -EINVAL;
+   }
+
+   /*
+* Make sure the file descriptor really is a cgroup fd and is on the
+* v2 hierarchy.
+*/
+   cgrp = cgroup_get_from_fd(req->cgroup_fd);
+   if (IS_ERR(cgrp)) {
+   DRM_DEBUG_DRIVER("Invalid cgroup file 

[PATCH v3 2/6] cgroup: Introduce task_get_dfl_cgroup()

2018-03-06 Thread Matt Roper
Wraps task_dfl_cgroup() to also take a reference to the cgroup.

Cc: Tejun Heo 
Cc: cgro...@vger.kernel.org
Signed-off-by: Matt Roper 
---
 include/linux/cgroup.h | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index a3604b005417..b1ea2064f247 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -527,6 +527,29 @@ static inline struct cgroup *task_dfl_cgroup(struct 
task_struct *task)
return task_css_set(task)->dfl_cgrp;
 }
 
+/**
+ * task_get_dfl_cgroup() - find and get the cgroup for a task
+ * @task: the target task
+ *
+ * Find the cgroup in the v2 hierarchy that a task belongs to, increment its
+ * reference count, and return it.
+ *
+ * Returns:
+ * The appropriate cgroup from the default hierarchy.
+ */
+static inline struct cgroup *
+task_get_dfl_cgroup(struct task_struct *task)
+{
+   struct cgroup *cgrp;
+
+   mutex_lock(_mutex);
+   cgrp = task_dfl_cgroup(task);
+   cgroup_get(cgrp);
+   mutex_unlock(_mutex);
+
+   return cgrp;
+}
+
 static inline struct cgroup *cgroup_parent(struct cgroup *cgrp)
 {
struct cgroup_subsys_state *parent_css = cgrp->self.parent;
-- 
2.14.3

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 0/6] DRM/i915 cgroup integration

2018-03-06 Thread Matt Roper
This is the third iteration of the work previously posted here:
  (v1) https://lists.freedesktop.org/archives/intel-gfx/2018-January/153156.html
  (v2) 
https://www.mail-archive.com/dri-devel@lists.freedesktop.org/msg208170.html

The high level goal of this work is to allow non-cgroup-controller parts
of the kernel (e.g., device drivers) to register their own private
policy data for specific cgroups.  That mechanism is then made use of in
the i915 graphics driver to allow GPU priority to be assigned according
to the cgroup membership of the owning process.  Please see the v1 cover
letter linked above for a more in-depth explanation and justification.

Key changes in v3 of this series:

 * The cgroup core interfaces have been redesigned as suggested by
   Tejun.  The cgroup core now supports the following:

void cgroup_priv_install(struct cgroup *cgrp,
 struct cgroup_priv *priv);
struct cgroup_priv *cgroup_priv_lookup(struct cgroup *cgrp,
   const void *key);
void cgroup_priv_free(struct cgroup *cgrp, const void *key);

 * Consumers of this interface may want to test the filesystem
   permissions of a cgroup to decide whether to allow custom syscalls or
   ioctls to operate on a cgroup's private data.  A new
   cgroup_permission(cgrp_fd, mask) function has been added to make this
   easier.

 * The i915 code looks up cgroup private data for 'current' rather than
   drm_file->pid to account for the device handle passing done by DRI3
   (i.e., the process that opened the device filehandle isn't
   necessarily the same process issuing ioctl's on it).

 * Other minor updates/changes based on feedback from Chris Wilson and
   Tejun Heo.


One open question on the i915 side of this work is whether we need to
limit the "priority offset" that can be assigned via cgroup (and if so,
what it should be limited to).  At the moment we make the assumption
that cgroup-based priority will be assigned by a privileged system
administrator / system integrator, so we accept any integer value they
choose to assign to the priority, even if it doesn't make sense.

As noted on previous iterations, the i915 userspace consumer for the
ioctl here is a simple i-g-t tool that will be sent shortly as a
followup on the intel-gfx list.  The tool itself is pretty trivial, but
that's intetional; the "real" userspace consumer of this work would
usually be something like a sysv-init script or systemd recipe that
would call that simple tool in an appropriate way to accomplish the
desired policy for a specific system.


Matt Roper (6):
  cgroup: Allow registration and lookup of cgroup private data
  cgroup: Introduce task_get_dfl_cgroup()
  cgroup: Introduce cgroup_permission()
  drm/i915: cgroup integration
  drm/i915: Introduce 'priority offset' for GPU contexts
  drm/i915: Add context priority & priority offset to debugfs (v2)

 drivers/gpu/drm/i915/Makefile   |   1 +
 drivers/gpu/drm/i915/i915_cgroup.c  | 214 
 drivers/gpu/drm/i915/i915_debugfs.c |   3 +
 drivers/gpu/drm/i915/i915_drv.c |   5 +
 drivers/gpu/drm/i915/i915_drv.h |  25 
 drivers/gpu/drm/i915/i915_gem_context.c |   7 +-
 drivers/gpu/drm/i915/i915_gem_context.h |   9 ++
 include/linux/cgroup-defs.h |  38 ++
 include/linux/cgroup.h  | 102 +++
 include/uapi/drm/i915_drm.h |  13 ++
 kernel/cgroup/cgroup.c  |  56 +
 11 files changed, 470 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/i915_cgroup.c

-- 
2.14.3

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: New KFD ioctls: taking the skeletons out of the closet

2018-03-06 Thread Jerome Glisse
On Tue, Mar 06, 2018 at 05:44:41PM -0500, Felix Kuehling wrote:
> Hi all,
> 
> Christian raised two potential issues in a recent KFD upstreaming code
> review that are related to the KFD ioctl APIs:
> 
>  1. behaviour of -ERESTARTSYS
>  2. transactional nature of KFD ioctl definitions, or lack thereof
> 
> I appreciate constructive feedback, but I also want to encourage an
> open-minded rather than a dogmatic approach to API definitions. So let
> me take all the skeletons out of my closet and get these APIs reviewed
> in the appropriate forum before we commit to them upstream. See the end
> of this email for reference.
> 
> The controversial part at this point is kfd_ioctl_map_memory_to_gpu. If
> any of the other APIs raise concerns or questions, please ask.
> 
> Because of the HSA programming model, KFD memory management APIs are
> synchronous. There is no pipelining. Command submission to GPUs through
> user mode queues does not involve KFD. This means KFD doesn't know what
> memory is used by the GPUs and when it's used. That means, when the
> map_memory_to_gpu ioctl returns to user mode, all memory mapping
> operations are complete and the memory can be used by the CPUs or GPUs
> immediately.
> 
> HSA also uses a shared virtual memory model, so typically memory gets
> mapped on multiple GPUs and CPUs at the same virtual address.

Does this means that GPU memory get pin ? Or system memory for that matter
too. This was discuss previously but this really goes against kernel mantra
ie kernel no longer manage resources but userspace can hog GPU memory or
even system memory. This is bad !

Cheers,
Jérôme
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 103234] KWin crashed when Alt+Tab-ing through open windows

2018-03-06 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103234

--- Comment #15 from Marek Olšák  ---
Can you get a backtrace with GALLIUM_THREAD=0 ? I'd like to know where indexbuf
== NULL is coming from.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH] drm/dp: Correctly mask DP_TRAINING_AUX_RD_INTERVAL values for DP 1.4

2018-03-06 Thread Rodrigo Vivi
On Tue, Mar 06, 2018 at 10:37:48AM -0800, matthew.s.atw...@intel.com wrote:
> From: Matt Atwood 
> 
> DP_TRAINING_AUX_RD_INTERVAL with DP 1.3 spec changed bit scheme from 8
> bits to 7 bits in DPCD 0x000e. The 8th bit describes a new feature, for
> panels that use this new feature, this would cause a wait interval for
> clock recovery of at least 512 ms, much higher then spec maximum of 16 ms.
> This behavior is described in table 2-158 of DP 1.4 spec address Eh.
> To avoid breaking panels that are not spec compliant we now warn on
> invalid values.
> 
> V2: commit title/message, masking all 7 bits, warn on out of spec values.

this approach is even better imho.

> 
> Signed-off-by: Matt Atwood 

Reviewed-by: Rodrigo Vivi 

> ---
>  drivers/gpu/drm/drm_dp_helper.c | 18 ++
>  include/drm/drm_dp_helper.h |  1 +
>  2 files changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index adf79be..a718ccc 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -119,18 +119,28 @@ u8 drm_dp_get_adjust_request_pre_emphasis(const u8 
> link_status[DP_LINK_STATUS_SI
>  EXPORT_SYMBOL(drm_dp_get_adjust_request_pre_emphasis);
>  
>  void drm_dp_link_train_clock_recovery_delay(const u8 
> dpcd[DP_RECEIVER_CAP_SIZE]) {
> - if (dpcd[DP_TRAINING_AUX_RD_INTERVAL] == 0)
> + int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & 
> DP_TRAINING_AUX_RD_MASK;
> +
> + if (rd_interval > 4)
> + DRM_DEBUG_KMS("AUX interval %d, out of range (max 4)", 
> rd_interval);
> +
> + if (rd_interval == 0)
>   udelay(100);
>   else
> - mdelay(dpcd[DP_TRAINING_AUX_RD_INTERVAL] * 4);
> + mdelay(rd_interval * 4);
>  }
>  EXPORT_SYMBOL(drm_dp_link_train_clock_recovery_delay);
>  
>  void drm_dp_link_train_channel_eq_delay(const u8 dpcd[DP_RECEIVER_CAP_SIZE]) 
> {
> - if (dpcd[DP_TRAINING_AUX_RD_INTERVAL] == 0)
> + int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & 
> DP_TRAINING_AUX_RD_MASK;
> +
> + if (rd_interval > 4)
> + DRM_DEBUG_KMS("AUX interval %d, out of range (max 4)", 
> rd_interval);
> +
> + if (rd_interval == 0)
>   udelay(400);
>   else
> - mdelay(dpcd[DP_TRAINING_AUX_RD_INTERVAL] * 4);
> + mdelay(rd_interval * 4);
>  }
>  EXPORT_SYMBOL(drm_dp_link_train_channel_eq_delay);
>  
> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> index da58a42..f80acf1 100644
> --- a/include/drm/drm_dp_helper.h
> +++ b/include/drm/drm_dp_helper.h
> @@ -118,6 +118,7 @@
>  # define DP_DPCD_DISPLAY_CONTROL_CAPABLE (1 << 3) /* edp v1.2 or higher 
> */
>  
>  #define DP_TRAINING_AUX_RD_INTERVAL 0x00e   /* XXX 1.2? */
> +# define DP_TRAINING_AUX_RD_MASK0x7F /* 1.3 */
>  
>  #define DP_ADAPTER_CAP   0x00f   /* 1.2 */
>  # define DP_FORCE_LOAD_SENSE_CAP (1 << 0)
> -- 
> 2.7.4
> 
> ___
> Intel-gfx mailing list
> intel-...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v6 5/9] drm: Handle aspect-ratio info in getblob

2018-03-06 Thread kbuild test robot
Hi Ankit,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm/drm-next]
[also build test WARNING on v4.16-rc4 next-20180306]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Nautiyal-Ankit-K/Aspect-ratio-support-in-DRM-layer/20180307-064609
base:   git://people.freedesktop.org/~airlied/linux.git drm-next
config: i386-randconfig-x015-201809 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   drivers/gpu/drm/drm_property.c: In function 'drm_mode_getblob_ioctl':
>> drivers/gpu/drm/drm_property.c:758:4: warning: cast to pointer from integer 
>> of different size [-Wint-to-pointer-cast]
   (struct drm_mode_modeinfo *) out_resp->data;
   ^

vim +758 drivers/gpu/drm/drm_property.c

   734  
   735  int drm_mode_getblob_ioctl(struct drm_device *dev,
   736 void *data, struct drm_file *file_priv)
   737  {
   738  struct drm_mode_get_blob *out_resp = data;
   739  struct drm_property_blob *blob;
   740  int ret = 0;
   741  
   742  if (!drm_core_check_feature(dev, DRIVER_MODESET))
   743  return -EINVAL;
   744  
   745  blob = drm_property_lookup_blob(dev, out_resp->blob_id);
   746  if (!blob)
   747  return -ENOENT;
   748  
   749  if (out_resp->length == blob->length) {
   750  if (copy_to_user(u64_to_user_ptr(out_resp->data),
   751   blob->data,
   752   blob->length)) {
   753  ret = -EFAULT;
   754  goto unref;
   755  }
   756  if (blob->is_video_mode) {
   757  struct drm_mode_modeinfo *mode =
 > 758  (struct drm_mode_modeinfo *) out_resp->data;
   759  drm_mode_handle_aspect_ratio(file_priv, 
>flags);
   760  }
   761  }
   762  out_resp->length = blob->length;
   763  unref:
   764  drm_property_blob_put(blob);
   765  
   766  return ret;
   767  }
   768  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC][PATCH 2/2 v4] drm_hwcomposer: Add platformhisi buffer importer for hikey and hikey960

2018-03-06 Thread John Stultz
This allows for importing buffers allocated from the
hikey and hikey960 gralloc implelementations.

Cc: Marissa Wall 
Cc: Sean Paul 
Cc: Dmitry Shmidt 
Cc: Robert Foss 
Cc: Matt Szczesiak 
Cc: Liviu Dudau 
Cc: David Hanna 
Cc: Rob Herring 
Cc: Alexandru-Cosmin Gheorghe 
Signed-off-by: John Stultz 
---
v2:
* Make platformhisi and the generic importer exclusive in the
  build
* Fixup vendor check
v3:
* Unify format conversions
* Subclass the platformdrmgeneric importer implementation to
  reduce code duplication
* Rework to avoid board specific logic (tweak gralloc to be
  consistent between the two)
v4:
* Minor cleanups as suggested by Alexandru-Cosmin Gheorghe
---
 Android.mk   |  13 +
 platformdrmgeneric.h |   2 +-
 platformhisi.cpp | 135 +++
 platformhisi.h   |  48 ++
 4 files changed, 197 insertions(+), 1 deletion(-)
 create mode 100644 platformhisi.cpp
 create mode 100644 platformhisi.h

diff --git a/Android.mk b/Android.mk
index ee5b8bf..f37e4c3 100644
--- a/Android.mk
+++ b/Android.mk
@@ -74,7 +74,20 @@ LOCAL_CPPFLAGS += \
-DHWC2_USE_CPP11 \
-DHWC2_INCLUDE_STRINGIFICATION
 
+
+ifeq ($(TARGET_PRODUCT),hikey960)
+LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER
+LOCAL_SRC_FILES += platformhisi.cpp
+LOCAL_C_INCLUDES += device/linaro/hikey/gralloc960/
+else
+ifeq ($(TARGET_PRODUCT),hikey)
+LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER
+LOCAL_SRC_FILES += platformhisi.cpp
+LOCAL_C_INCLUDES += device/linaro/hikey/gralloc/
+else
 LOCAL_CPPFLAGS += -DUSE_DRM_GENERIC_IMPORTER
+endif
+endif
 
 LOCAL_MODULE := hwcomposer.drm
 LOCAL_MODULE_TAGS := optional
diff --git a/platformdrmgeneric.h b/platformdrmgeneric.h
index 8376580..fbe059b 100644
--- a/platformdrmgeneric.h
+++ b/platformdrmgeneric.h
@@ -35,8 +35,8 @@ class DrmGenericImporter : public Importer {
   int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
   int ReleaseBuffer(hwc_drm_bo_t *bo) override;
 
- private:
   uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
+ private:
 
   DrmResources *drm_;
 
diff --git a/platformhisi.cpp b/platformhisi.cpp
new file mode 100644
index 000..16c5e6f
--- /dev/null
+++ b/platformhisi.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "hwc-platform-hisi"
+
+#include "drmresources.h"
+#include "platform.h"
+#include "platformhisi.h"
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include "gralloc_priv.h"
+
+
+namespace android {
+
+Importer *Importer::CreateInstance(DrmResources *drm) {
+  HisiImporter *importer = new HisiImporter(drm);
+  if (!importer)
+return NULL;
+
+  int ret = importer->Init();
+  if (ret) {
+ALOGE("Failed to initialize the hisi importer %d", ret);
+delete importer;
+return NULL;
+  }
+  return importer;
+}
+
+HisiImporter::HisiImporter(DrmResources *drm) : DrmGenericImporter(drm), 
drm_(drm) {
+}
+
+HisiImporter::~HisiImporter() {
+}
+
+int HisiImporter::Init() {
+  int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
+  (const hw_module_t **)_);
+  if (ret) {
+ALOGE("Failed to open gralloc module %d", ret);
+return ret;
+  }
+
+  if (strcasecmp(gralloc_->common.author, "ARM Ltd."))
+ALOGW("Using non-ARM gralloc module: %s/%s\n", gralloc_->common.name,
+  gralloc_->common.author);
+
+  return 0;
+}
+
+EGLImageKHR HisiImporter::ImportImage(EGLDisplay egl_display, buffer_handle_t 
handle) {
+  private_handle_t const *hnd = reinterpret_cast < private_handle_t const 
*>(handle);
+  if (!hnd)
+return NULL;
+
+  EGLint fmt = ConvertHalFormatToDrm(hnd->req_format);
+  if (fmt < 0)
+   return NULL;
+
+  EGLint attr[] = {
+EGL_WIDTH, hnd->width,
+EGL_HEIGHT, hnd->height,
+EGL_LINUX_DRM_FOURCC_EXT, fmt,
+EGL_DMA_BUF_PLANE0_FD_EXT, hnd->share_fd,
+EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
+EGL_DMA_BUF_PLANE0_PITCH_EXT, hnd->byte_stride,
+EGL_NONE,
+  };
+  return eglCreateImageKHR(egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, 
NULL, attr);
+}
+
+int HisiImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
+  

[RFC][PATCH 1/2] drm_hwcomposer: Error out on YUV layer as it would fail for single planes

2018-03-06 Thread John Stultz
As suggested by Alexandru-Cosmin Gheorghe:

ConvertHALFormatToDrm logic would work only for 1 plane formats,
and probably gets rejected by drmModeAddFb2, but to save
debugging time  maybe it worth removing DRM_FORMAT_YVU420 from
ConvertHALFormatToDrm and checking it's return code.

So this patch tries to do this.

Cc: Marissa Wall 
Cc: Sean Paul 
Cc: Dmitry Shmidt 
Cc: Robert Foss 
Cc: Matt Szczesiak 
Cc: Liviu Dudau 
Cc: David Hanna 
Cc: Rob Herring 
Cc: Alexandru-Cosmin Gheorghe 
Signed-off-by: John Stultz 
---
 platformdrmgeneric.cpp | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/platformdrmgeneric.cpp b/platformdrmgeneric.cpp
index 741d42b..33f1ea0 100644
--- a/platformdrmgeneric.cpp
+++ b/platformdrmgeneric.cpp
@@ -76,8 +76,6 @@ uint32_t DrmGenericImporter::ConvertHalFormatToDrm(uint32_t 
hal_format) {
   return DRM_FORMAT_ABGR;
 case HAL_PIXEL_FORMAT_RGB_565:
   return DRM_FORMAT_BGR565;
-case HAL_PIXEL_FORMAT_YV12:
-  return DRM_FORMAT_YVU420;
 default:
   ALOGE("Cannot convert hal format to drm format %u", hal_format);
   return -EINVAL;
@@ -88,10 +86,15 @@ EGLImageKHR DrmGenericImporter::ImportImage(EGLDisplay 
egl_display, buffer_handl
   gralloc_drm_handle_t *gr_handle = gralloc_drm_handle(handle);
   if (!gr_handle)
 return NULL;
+
+  EGLint fmt = ConvertHalFormatToDrm(gr_handle->format);
+  if (fmt < 0)
+   return NULL;
+
   EGLint attr[] = {
 EGL_WIDTH, gr_handle->width,
 EGL_HEIGHT, gr_handle->height,
-EGL_LINUX_DRM_FOURCC_EXT, (EGLint)ConvertHalFormatToDrm(gr_handle->format),
+EGL_LINUX_DRM_FOURCC_EXT, fmt,
 EGL_DMA_BUF_PLANE0_FD_EXT, gr_handle->prime_fd,
 EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
 EGL_DMA_BUF_PLANE0_PITCH_EXT, gr_handle->stride,
@@ -112,10 +115,14 @@ int DrmGenericImporter::ImportBuffer(buffer_handle_t 
handle, hwc_drm_bo_t *bo) {
 return ret;
   }
 
+  uint32_t  fmt = ConvertHalFormatToDrm(gr_handle->format);
+  if (fmt < 0)
+return fmt;
+
   memset(bo, 0, sizeof(hwc_drm_bo_t));
   bo->width = gr_handle->width;
   bo->height = gr_handle->height;
-  bo->format = ConvertHalFormatToDrm(gr_handle->format);
+  bo->format = fmt;
   bo->usage = gr_handle->usage;
   bo->pitches[0] = gr_handle->stride;
   bo->gem_handles[0] = gem_handle;
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: New KFD ioctls: taking the skeletons out of the closet

2018-03-06 Thread Dave Airlie
On 7 March 2018 at 08:44, Felix Kuehling  wrote:
> Hi all,
>
> Christian raised two potential issues in a recent KFD upstreaming code
> review that are related to the KFD ioctl APIs:
>
>  1. behaviour of -ERESTARTSYS
>  2. transactional nature of KFD ioctl definitions, or lack thereof
>
> I appreciate constructive feedback, but I also want to encourage an
> open-minded rather than a dogmatic approach to API definitions. So let
> me take all the skeletons out of my closet and get these APIs reviewed
> in the appropriate forum before we commit to them upstream. See the end
> of this email for reference.
>
> The controversial part at this point is kfd_ioctl_map_memory_to_gpu. If
> any of the other APIs raise concerns or questions, please ask.
>
> Because of the HSA programming model, KFD memory management APIs are
> synchronous. There is no pipelining. Command submission to GPUs through
> user mode queues does not involve KFD. This means KFD doesn't know what
> memory is used by the GPUs and when it's used. That means, when the
> map_memory_to_gpu ioctl returns to user mode, all memory mapping
> operations are complete and the memory can be used by the CPUs or GPUs
> immediately.

I've got a few opinions, but first up I still dislike user-mode queues
and everything
they entail. I still feel they are solving a Windows problem and not a
Linux problem,
and it would be nice if we had some Linux numbers on what they gain us over
a dispatch ioctl, because they sure bring a lot of memory management issues.

That said amdkfd is here.

The first question you should ask (which you haven't asked here at all) is
what should userspace do with the ioctl result.

>
> HSA also uses a shared virtual memory model, so typically memory gets
> mapped on multiple GPUs and CPUs at the same virtual address.
>
> The point of contention seems to be the ability to map memory to
> multiple GPUs in a single ioctl and the behaviour in failure cases. I'll
> discuss two main failure cases:
>
> 1: Failure after all mappings have been dispatched via SDMA, but a
> signal interrupts the wait for completion and we return -ERESTARTSYS.
> Documentation/kernel-hacking/hacking.rst only says "[...] you should be
> prepared to process the restart, e.g. if you're in the middle of
> manipulating some data structure." I think we do that by ensuring that
> memory that's already mapped won't be mapped again. So the restart will
> become a no-op and just end up waiting for all the previous mappings to
> complete.

-ERESTARTSYS at that late stage points to a badly synchronous API,
I'd have said you should have two ioctls, one that returns a fence after
starting the processes, and one that waits for the fence separately.

The overhead of ioctls isn't your enemy until you've measured it and
proven it's a problem.

>
> Christian has a stricter requirement, and I'd like to know where that
> comes from: "An interrupted IOCTL should never have a visible effect."

Christian might be taking things a bit further but synchronous gpu access
APIs are bad, but I don't think undoing a bunch of work is a good plan either
just because you got ERESTARTSYS. If you get ERESTARTSYS can you
handle it, if I've fired off 5 SDMAs and wait for them will I fire off 5 more?
will I wait for the original SDMAs if I reenter?

>
> 2: Failure to map on some but not all GPUs. This comes down to the
> question, do all ioctl APIs or system calls in general need to be
> transactional? As a counter example I'd give incomplete read or write
> system calls that return how much was actually read or written. Our
> current implementation of map_memory_to_gpu doesn't do this, but it
> could be modified to return to user mode how many of the mappings, or
> which mappings specifically failed or succeeded.

What should userspace do? if it only get mappings on 3 of the gpus instead
of say 4? Is there a sane resolution other than calling the ioctl again with
the single GPU? Would it drop the GPU from the working set from that point on?

Need more info to do what can come out of the API doing incomplete
operations.

> The alternative would be to break multi-GPU mappings, and the final wait
> for completion, into multiple ioctl calls. That would result in
> additional system call overhead. I'd argue that the end result is the
> same for user mode, so I don't see why I'd use multiple ioctls over a
> single one.

Again stop worrying about ioctl overhead, this isn't Windows. If you
can show the overhead as being a problem then address it, but I
think it's premature worrying about it at this stage.

Dave.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCHv2 5/7] cec-pin: add error injection support

2018-03-06 Thread Hans Verkuil
On 05/03/18 14:51, Hans Verkuil wrote:
> From: Hans Verkuil 
> 
> Implement all the error injection commands.
> 
> The state machine gets new states for the various error situations,
> helper functions are added to detect whether an error injection is
> active and the actual error injections are implemented.
> 
> Signed-off-by: Hans Verkuil 
> ---
>  drivers/media/cec/cec-pin-priv.h |  38 ++-
>  drivers/media/cec/cec-pin.c  | 542 
> +++
>  2 files changed, 521 insertions(+), 59 deletions(-)
> 
> diff --git a/drivers/media/cec/cec-pin-priv.h 
> b/drivers/media/cec/cec-pin-priv.h
> index 779384f18689..c9349f68e554 100644
> --- a/drivers/media/cec/cec-pin-priv.h
> +++ b/drivers/media/cec/cec-pin-priv.h



> +static bool tx_error_inj(struct cec_pin *pin, unsigned int mode_offset,
> +  int arg_idx, u8 *arg)
> +{
> +#ifdef CONFIG_CEC_PIN_ERROR_INJ
> + u16 cmd = cec_pin_tx_error_inj(pin);
> + u64 e = pin->error_inj[cmd];
> + unsigned int mode = (e >> mode_offset) & CEC_ERROR_INJ_MODE_MASK;
> +
> + if (arg_idx) {

Oops, this should be arg_idx >= 0. It's -1 if there is no argument associated
with the error injection command.

> + u8 pos = pin->error_inj_args[cmd][arg_idx];
> +
> + if (arg)
> + *arg = pos;
> + else if (pos != pin->tx_bit)
> + return false;
> + }
> +
> + switch (mode) {
> + case CEC_ERROR_INJ_MODE_ONCE:
> + pin->error_inj[cmd] &= ~(CEC_ERROR_INJ_MODE_MASK << 
> mode_offset);
> + return true;
> + case CEC_ERROR_INJ_MODE_ALWAYS:
> + return true;
> + case CEC_ERROR_INJ_MODE_TOGGLE:
> + return pin->tx_toggle;
> + default:
> + return false;
> + }
> +#else
> + return false;
> +#endif
> +}



> + case EOM_BIT:
> + v = pin->tx_bit / 10 ==
> + pin->tx_msg.len + pin->tx_extra_bytes - 1;
> + if (pin->tx_msg.len > 1 && tx_early_eom(pin)) {

tx_early_eom should only be called for the second-to-last byte.

> + /* Error injection: set EOM one byte early */
> + v = pin->tx_bit / 10 ==
> + pin->tx_msg.len + pin->tx_extra_bytes - 
> 2;
> + pin->tx_post_eom = true;
> + }
> + if (tx_no_eom(pin)) {

Ditto for tx_no_eom: only call for the last byte.

Otherwise for mode 'once' this error injection command will be cleared
before the end of the message is reached.

> + /* Error injection: no EOM */
> + v = false;
> + }
>   pin->state = v ? CEC_ST_TX_DATA_BIT_1_LOW :
> - CEC_ST_TX_DATA_BIT_0_LOW;
> +  CEC_ST_TX_DATA_BIT_0_LOW;
>   break;

Regards,

Hans
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


New KFD ioctls: taking the skeletons out of the closet

2018-03-06 Thread Felix Kuehling
Hi all,

Christian raised two potential issues in a recent KFD upstreaming code
review that are related to the KFD ioctl APIs:

 1. behaviour of -ERESTARTSYS
 2. transactional nature of KFD ioctl definitions, or lack thereof

I appreciate constructive feedback, but I also want to encourage an
open-minded rather than a dogmatic approach to API definitions. So let
me take all the skeletons out of my closet and get these APIs reviewed
in the appropriate forum before we commit to them upstream. See the end
of this email for reference.

The controversial part at this point is kfd_ioctl_map_memory_to_gpu. If
any of the other APIs raise concerns or questions, please ask.

Because of the HSA programming model, KFD memory management APIs are
synchronous. There is no pipelining. Command submission to GPUs through
user mode queues does not involve KFD. This means KFD doesn't know what
memory is used by the GPUs and when it's used. That means, when the
map_memory_to_gpu ioctl returns to user mode, all memory mapping
operations are complete and the memory can be used by the CPUs or GPUs
immediately.

HSA also uses a shared virtual memory model, so typically memory gets
mapped on multiple GPUs and CPUs at the same virtual address.

The point of contention seems to be the ability to map memory to
multiple GPUs in a single ioctl and the behaviour in failure cases. I'll
discuss two main failure cases:

1: Failure after all mappings have been dispatched via SDMA, but a
signal interrupts the wait for completion and we return -ERESTARTSYS.
Documentation/kernel-hacking/hacking.rst only says "[...] you should be
prepared to process the restart, e.g. if you're in the middle of
manipulating some data structure." I think we do that by ensuring that
memory that's already mapped won't be mapped again. So the restart will
become a no-op and just end up waiting for all the previous mappings to
complete.

Christian has a stricter requirement, and I'd like to know where that
comes from: "An interrupted IOCTL should never have a visible effect."

2: Failure to map on some but not all GPUs. This comes down to the
question, do all ioctl APIs or system calls in general need to be
transactional? As a counter example I'd give incomplete read or write
system calls that return how much was actually read or written. Our
current implementation of map_memory_to_gpu doesn't do this, but it
could be modified to return to user mode how many of the mappings, or
which mappings specifically failed or succeeded.

I'd like to know whether such behaviour is acceptable.

The alternative would be to break multi-GPU mappings, and the final wait
for completion, into multiple ioctl calls. That would result in
additional system call overhead. I'd argue that the end result is the
same for user mode, so I don't see why I'd use multiple ioctls over a
single one.

I'm looking forward to your feedback.

Thanks,
  Felix


Reference: After the last rework, these are the ioctls I'm hoping to
upstream in my current patch series (with annotations):

/* Acquire a VM from a DRM render node FD for use by KFD on a specific device
 *
 * @drm_fd: DRM render node file descriptor
 * @gpu_id: device identifier (used throughout the KFD API)
 */
struct kfd_ioctl_acquire_vm_args {
__u32 drm_fd;   /* to KFD */
__u32 gpu_id;   /* to KFD */
};

/* Allocation flags: memory types */
#define KFD_IOC_ALLOC_MEM_FLAGS_VRAM(1 << 0)
#define KFD_IOC_ALLOC_MEM_FLAGS_GTT (1 << 1)
#define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR (1 << 2)
#define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL(1 << 3)
/* Allocation flags: attributes/access options */
#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE(1 << 31)
#define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE  (1 << 30)
#define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC  (1 << 29)
#define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE   (1 << 28)
#define KFD_IOC_ALLOC_MEM_FLAGS_AQL_QUEUE_MEM   (1 << 27)
#define KFD_IOC_ALLOC_MEM_FLAGS_COHERENT(1 << 26)

/* Allocate memory for later SVM (shared virtual memory) mapping.
 *
 * @va_addr: virtual address of the memory to be allocated
 *   all later mappings on all GPUs will use this address
 * @size:size in bytes
 * @handle:  buffer handle returned to user mode, used to refer to
 *   this allocation for mapping, unmapping and freeing
 * @mmap_offset: for CPU-mapping the allocation by mmapping a render node
 *   for userptrs this is overloaded to specify the CPU address
 * @gpu_id:  device identifier
 * @flags:   memory type and attributes. See KFD_IOC_ALLOC_MEM_FLAGS above
 */
struct kfd_ioctl_alloc_memory_of_gpu_args {
__u64 va_addr;  /* to KFD */
__u64 size; /* to KFD */
__u64 handle;   /* from KFD */
__u64 mmap_offset;  /* to KFD (userptr), from KFD (mmap offset) */
__u32 gpu_id;   /* to KFD */
__u32 flags;
};

/* Free memory 

Re: Overlay sugar syntax (was: Re: [PATCH v6 3/4] drm: rcar-du: Fix legacy DT to create LVDS encoder nodes)

2018-03-06 Thread Rob Herring
On Tue, Mar 6, 2018 at 8:07 AM, David Gibson
 wrote:
> On Tue, Mar 06, 2018 at 01:30:05PM +0100, Geert Uytterhoeven wrote:
>> Hi David,
>>
>> On Tue, Mar 6, 2018 at 4:54 AM, David Gibson
>>  wrote:
>> > On Fri, Feb 23, 2018 at 09:05:24AM +0100, Geert Uytterhoeven wrote:
>> >> On Fri, Feb 23, 2018 at 3:38 AM, Frank Rowand  
>> >> wrote:
>> >> > I was hoping to be able to convert the .dts files to use sugar syntax
>> >> > instead of hand coding the fragment nodes, but for this specific set
>> >> > of files I failed, since the labels that would have been required do
>> >> > not already exist in the base .dts files that that overlays would be
>> >> > applied against.
>> >>
>> >> Indeed, hence the fixup overlays use "target-path".
>> >>
>> >> BTW, is there any specific reason there is no sugar syntax support in dtc
>> >> for absolute target paths? I guess to prevent adding stuff to a random
>> >> existing node, and to encourage people to use a "connector" API defined in
>> >> term of labels?
>> >
>> > Only because it hasn't been implemented.  Using &{/whatever} should
>> > IMO generate a target-path and the fact it doesn't is a bug.
>> >
>> >> I'm also in the process of converting my collection of DT overlays to 
>> >> sugar
>> >> syntax, and lack of support for "target-path" is the sole thing that holds
>> >> me back from completing this. So for now I use a mix of sugar and
>> >> traditional overlay syntax.
>> >>
>> >> In particular, I need "target-path" for two things:
>> >>   1. To refer to the root node, for adding devices that should live at
>> >>  (a board subnode of) the root node, like:
>> >>- devices connected to GPIO controllers provided by other base or
>> >>  overlay devices (e.g. LEDs, displays, buttons, ...),
>> >>- clock providers for other overlays devices (e.g. fixed-clock).
>>
>> >> The former is the real blocker for me.
>>
>> > Below is draft patch adding target-path support.  The pretty minimal
>> > test examples do include a case using &{/}
>> >
>> > From 8f1b35f88395adea01ce1100c5faa27dacbc8410 Mon Sep 17 00:00:00 2001
>> > From: David Gibson 
>> > Date: Tue, 6 Mar 2018 13:27:53 +1100
>> > Subject: [PATCH] Correct overlay syntactic sugar for generating target-path
>> >  fragments
>> >
>> > We've recently added "syntactic sugar" support to generate runtime dtb
>> > overlays using similar syntax to the compile time overlays we've had for
>> > a while.  This worked with the  { ... } syntax, adjusting an existing
>> > labelled node, but would fail with the &{/path} { ... } syntax attempting
>> > to adjust an existing node referenced by its path.
>> >
>> > The previous code would always try to use the "target" property in the
>> > output overlay, which needs to be fixed up, and __fixups__ can only encode
>> > symbols, not paths, so the result could never work properly.
>> >
>> > This adds support for the &{/path} syntax for overlays, translating it into
>> > the "target-path" encoding in the output.  It also changes existing
>> > behaviour a little because we now unconditionally one fragment for each
>> > overlay section in the source.  Previously we would only create a fragment
>> > if we couldn't locally resolve the node referenced.  We need this for
>> > path references, because the path is supposed to be referencing something
>> > in the (not yet known) base tree, rather than the overlay tree we are
>> > working with now.  In particular one useful case for path based overlays
>> > is using &{/} - but the constructed overlay tree will always have a root
>> > node, meaning that without the change that would attempt to resolve the
>> > fragment locally, which is not what we want.
>> >
>> > Signed-off-by: David Gibson 
>>
>> Thank you, seems to work fine on dtc.git.
>>
>> Note that while the dtc part applies on the in-kernel copy of dtc, it
>> doesn't work there: "&{/}" behaves the same as "/" (i.e. no overlay
>> fragment is generated), but "&{/foo}" does create the overlay fragment.
>> Merging in Rob's for-next branch to upgrade Linux' copy of dtc fixes
>> that.
>
> I think that'll be because the kernel makefiles (at least by default)
> use a pre-generated version of the parser, rather than running bison.

Just FYI, as of that branch, that is no longer true. We now run bison.

> Since there were changes in the .y file, those will be missing which
> would cause the error you describe.
>
> --
> David Gibson| I'll have my music baroque, and my code
> david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
> | _way_ _around_!
> http://www.ozlabs.org/~dgibson
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 6/6] drm/amdgpu: explicit give BO type to amdgpu_bo_create

2018-03-06 Thread Felix Kuehling
NAK.

For KFD we need the ability to create a BO from an SG list that doesn't
come from another BO. We use this for mapping pages from the doorbell
aperture into GPUVM for GPU self-dispatch.

If you remove this now, I'll need to add it back in some form in a month
or two when I get to that part of upstreaming KFD.

There may be other ways to implement this. Currently we need to create a
BO for anything we want to map into a GPUVM page table, because the
amdgpu_vm code is based around BOs. If there was a way to map physical
addresses into GPUVM without creating a buffer object, that would work too.

Regards,
  Felix


On 2018-03-06 09:43 AM, Christian König wrote:
> Drop the "kernel" and sg parameter and give the BO type to create
> explicit to amdgpu_bo_create instead of figuring it out from the
> parameters.
>
> Signed-off-by: Christian König 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c|  5 +--
>  drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c |  8 ++---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c  |  7 ++--
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c   |  6 ++--
>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c| 46 
> +++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.h| 11 +++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c |  7 ++--
>  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c  | 11 +++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   | 11 ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c|  8 ++---
>  11 files changed, 58 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 292c7e72820c..b1116b773516 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -441,7 +441,7 @@ struct amdgpu_sa_bo {
>  void amdgpu_gem_force_release(struct amdgpu_device *adev);
>  int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
>int alignment, u32 initial_domain,
> -  u64 flags, bool kernel,
> +  u64 flags, enum ttm_bo_type type,
>struct reservation_object *resv,
>struct drm_gem_object **obj);
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> index 450426dbed92..7f096ed6e83d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> @@ -215,8 +215,9 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size,
>   if ((*mem) == NULL)
>   return -ENOMEM;
>  
> - r = amdgpu_bo_create(adev, size, PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_GTT,
> -  AMDGPU_GEM_CREATE_CPU_GTT_USWC, NULL, NULL, 
> &(*mem)->bo);
> + r = amdgpu_bo_create(adev, size, PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,
> +  AMDGPU_GEM_CREATE_CPU_GTT_USWC, ttm_bo_type_kernel,
> +  NULL, &(*mem)->bo);
>   if (r) {
>   dev_err(adev->dev,
>   "failed to allocate BO for amdkfd (%d)\n", r);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> index 2fb299afc12b..02b849be083b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> @@ -80,8 +80,8 @@ static void amdgpu_benchmark_move(struct amdgpu_device 
> *adev, unsigned size,
>   int time;
>  
>   n = AMDGPU_BENCHMARK_ITERATIONS;
> - r = amdgpu_bo_create(adev, size, PAGE_SIZE, true, sdomain, 0, NULL,
> -  NULL, );
> + r = amdgpu_bo_create(adev, size, PAGE_SIZE,sdomain, 0,
> +  ttm_bo_type_kernel, NULL, );
>   if (r) {
>   goto out_cleanup;
>   }
> @@ -93,8 +93,8 @@ static void amdgpu_benchmark_move(struct amdgpu_device 
> *adev, unsigned size,
>   if (r) {
>   goto out_cleanup;
>   }
> - r = amdgpu_bo_create(adev, size, PAGE_SIZE, true, ddomain, 0, NULL,
> -  NULL, );
> + r = amdgpu_bo_create(adev, size, PAGE_SIZE, ddomain, 0,
> +  ttm_bo_type_kernel, NULL, );
>   if (r) {
>   goto out_cleanup;
>   }
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> index dc8d9f3216fa..cf0f186c6092 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> @@ -113,11 +113,12 @@ int amdgpu_gart_table_vram_alloc(struct amdgpu_device 
> *adev)
>   int r;
>  
>   if (adev->gart.robj == NULL) {
> - r = amdgpu_bo_create(adev, adev->gart.table_size,
> -  PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM,
> + r = amdgpu_bo_create(adev, 

[RFC][PATCH] libdrm: gralloc_handle.h: Fix build issue with Android

2018-03-06 Thread John Stultz
In trying to integrate the new gralloc_handle.h with the
drm_hwcomposer, I started seeing the following compilation
errors:

In file included from external/drm_hwcomposer/platformdrmgeneric.cpp:28:
external/libdrm/android/gralloc_handle.h:108:9: error: cannot initialize return 
object of type 'native_handle_t *' (aka 'native_handle *') with an lvalue of 
type 'struct gralloc_handle_t *'
return handle;
   ^~
1 error generated.

This seems to be due to the gralloc_handle_create() definition
claiming to return a native_handle_t * type, rather then a
gralloc_handle_t *, which is what the code actually returns.

This function isn't actually used in the current drm_hwcomposer,
so I'm not totally sure that this fix is correct (rather then
returning the gralloc_handle_t's embadedded native_handle_t ptr).

But it seems something like this is needed.

Cc: Robert Foss 
Cc: Rob Herring 
Signed-off-by: John Stultz 
---
 android/gralloc_handle.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index 9cb5a5d..6e925c9 100644
--- a/android/gralloc_handle.h
+++ b/android/gralloc_handle.h
@@ -84,7 +84,7 @@ static inline struct gralloc_handle_t 
*gralloc_handle(buffer_handle_t handle)
 /**
  * Create a buffer handle.
  */
-static inline native_handle_t *gralloc_handle_create(int32_t width,
+static inline gralloc_handle_t *gralloc_handle_create(int32_t width,
  int32_t height,
  int32_t hal_format,
  int32_t usage)
@@ -107,5 +107,4 @@ static inline native_handle_t 
*gralloc_handle_create(int32_t width,
 
return handle;
 }
-
 #endif
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 105089] radeonsi GPU lockup / crash with wine [The Witcher 3]

2018-03-06 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105089

mirh  changed:

   What|Removed |Added

 CC||m...@protonmail.ch

--- Comment #3 from mirh  ---
I wonder if this could be any related to bug 104193?

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/3] drm/vc4: Set premultiplied for alpha formats

2018-03-06 Thread Stefan Schake
On Tue, Mar 6, 2018 at 8:35 PM, Eric Anholt  wrote:
> Stefan Schake  writes:
>
>> Alpha formats in DRM are assumed to be premultiplied, so we should be
>> setting the PREMULT bit in the plane configuration for HVS.
>>
>> Signed-off-by: Stefan Schake 
>> ---
>>  drivers/gpu/drm/vc4/vc4_plane.c | 3 ++-
>>  drivers/gpu/drm/vc4/vc4_regs.h  | 1 +
>>  2 files changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/vc4/vc4_plane.c 
>> b/drivers/gpu/drm/vc4/vc4_plane.c
>> index c4c7af1..3d0c8a2 100644
>> --- a/drivers/gpu/drm/vc4/vc4_plane.c
>> +++ b/drivers/gpu/drm/vc4/vc4_plane.c
>> @@ -618,13 +618,14 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
>> SCALER_POS1_SCL_HEIGHT));
>>   }
>>
>> - /* Position Word 2: Source Image Size, Alpha Mode */
>> + /* Position Word 2: Source Image Size, Alpha */
>>   vc4_state->pos2_offset = vc4_state->dlist_count;
>>   vc4_dlist_write(vc4_state,
>>   VC4_SET_FIELD(fb->format->has_alpha ?
>> SCALER_POS2_ALPHA_MODE_PIPELINE :
>> SCALER_POS2_ALPHA_MODE_FIXED,
>> SCALER_POS2_ALPHA_MODE) |
>> + (format->has_alpha ? SCALER_POS2_ALPHA_PREMULT : 0) |
>
> Looks like you meant fb->format->has_alpha here.  I can fix that up when
> applying -- everything else looks good to me.  I'll let this sit on the
> list for a day or two in case anyone else has feedback.

I remember fixing that up, and I did - but in 2/3, where of course it
doesn't really belong. Sorry, I must have gotten my rebase mixed up.

Since that makes two patches that need fixups, would you prefer I send
a v2 instead?

Thanks,
Stefan
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/3] drm/vc4: Check if plane requires background fill

2018-03-06 Thread Ville Syrjälä
On Tue, Mar 06, 2018 at 02:48:38AM +0100, Stefan Schake wrote:
> Considering a single plane only, we have to enable background color
> when the plane has an alpha format and could be blending from the
> background or when it doesn't cover the entire screen.
> 
> Signed-off-by: Stefan Schake 
> ---
>  drivers/gpu/drm/vc4/vc4_drv.h   |  6 ++
>  drivers/gpu/drm/vc4/vc4_plane.c | 15 ++-
>  2 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
> index fefa166..7cc6390 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.h
> +++ b/drivers/gpu/drm/vc4/vc4_drv.h
> @@ -302,6 +302,12 @@ struct vc4_hvs {
>  
>  struct vc4_plane {
>   struct drm_plane base;
> +
> + /* Set when the plane has per-pixel alpha content or does not cover
> +  * the entire screen. This is a hint to the CRTC that it might need
> +  * to enable background color fill.
> +  */
> + bool needs_bg_fill;

Looks to me like that should really be a bitmask (or something similar)
in the crtc state.

>  };
>  
>  static inline struct vc4_plane *
> diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
> index 3d0c8a2..c299e29 100644
> --- a/drivers/gpu/drm/vc4/vc4_plane.c
> +++ b/drivers/gpu/drm/vc4/vc4_plane.c
> @@ -517,10 +517,12 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
>  {
>   struct vc4_dev *vc4 = to_vc4_dev(plane->dev);
>   struct vc4_plane_state *vc4_state = to_vc4_plane_state(state);
> + struct vc4_plane *vc4_plane = to_vc4_plane(plane);
>   struct drm_framebuffer *fb = state->fb;
>   u32 ctl0_offset = vc4_state->dlist_count;
>   const struct hvs_format *format = 
> vc4_get_hvs_format(fb->format->format);
>   int num_planes = drm_format_num_planes(format->drm);
> + bool covers_screen;
>   u32 scl0, scl1, pitch0;
>   u32 lbm_size, tiling;
>   unsigned long irqflags;
> @@ -625,7 +627,7 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
> SCALER_POS2_ALPHA_MODE_PIPELINE :
> SCALER_POS2_ALPHA_MODE_FIXED,
> SCALER_POS2_ALPHA_MODE) |
> - (format->has_alpha ? SCALER_POS2_ALPHA_PREMULT : 0) |
> + (fb->format->has_alpha ? SCALER_POS2_ALPHA_PREMULT : 0) 
> |
>   VC4_SET_FIELD(vc4_state->src_w[0], SCALER_POS2_WIDTH) |
>   VC4_SET_FIELD(vc4_state->src_h[0], SCALER_POS2_HEIGHT));
>  
> @@ -701,6 +703,17 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
>   vc4_state->dlist[ctl0_offset] |=
>   VC4_SET_FIELD(vc4_state->dlist_count, SCALER_CTL0_SIZE);
>  
> + /* crtc_* are already clipped coordinates. */
> + covers_screen = vc4_state->crtc_x == 0 && vc4_state->crtc_y == 0 &&
> + vc4_state->crtc_w == state->crtc->mode.hdisplay &&
> + vc4_state->crtc_h == state->crtc->mode.vdisplay;
> + /* Background fill might be necessary when the plane has per-pixel
> +  * alpha content and blends from the background or does not cover
> +  * the entire screen.
> +  */
> + vc4_plane->needs_bg_fill = fb->format->has_alpha || !covers_screen;
> +
> +
>   return 0;
>  }
>  
> -- 
> 2.7.4
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/3] drm/vc4: Set premultiplied for alpha formats

2018-03-06 Thread Eric Anholt
Stefan Schake  writes:

> Alpha formats in DRM are assumed to be premultiplied, so we should be
> setting the PREMULT bit in the plane configuration for HVS.
>
> Signed-off-by: Stefan Schake 
> ---
>  drivers/gpu/drm/vc4/vc4_plane.c | 3 ++-
>  drivers/gpu/drm/vc4/vc4_regs.h  | 1 +
>  2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
> index c4c7af1..3d0c8a2 100644
> --- a/drivers/gpu/drm/vc4/vc4_plane.c
> +++ b/drivers/gpu/drm/vc4/vc4_plane.c
> @@ -618,13 +618,14 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
> SCALER_POS1_SCL_HEIGHT));
>   }
>  
> - /* Position Word 2: Source Image Size, Alpha Mode */
> + /* Position Word 2: Source Image Size, Alpha */
>   vc4_state->pos2_offset = vc4_state->dlist_count;
>   vc4_dlist_write(vc4_state,
>   VC4_SET_FIELD(fb->format->has_alpha ?
> SCALER_POS2_ALPHA_MODE_PIPELINE :
> SCALER_POS2_ALPHA_MODE_FIXED,
> SCALER_POS2_ALPHA_MODE) |
> + (format->has_alpha ? SCALER_POS2_ALPHA_PREMULT : 0) |

Looks like you meant fb->format->has_alpha here.  I can fix that up when
applying -- everything else looks good to me.  I'll let this sit on the
list for a day or two in case anyone else has feedback.


signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PULL] drm-misc-next

2018-03-06 Thread Sean Paul
On Tue, Mar 06, 2018 at 09:07:52PM +0200, Ville Syrjälä wrote:
> On Tue, Mar 06, 2018 at 02:01:21PM -0500, Sean Paul wrote:
> > On Tue, Mar 06, 2018 at 07:42:53AM +0100, Daniel Vetter wrote:
> > > On Tue, Mar 6, 2018 at 12:20 AM, Sean Paul  wrote:
> > > > On Mon, Mar 5, 2018 at 12:10 AM, Daniel Vetter  wrote:
> > > >> On Fri, Mar 02, 2018 at 04:22:15PM -0500, Sean Paul wrote:
> > > >>> On Wed, Feb 28, 2018 at 3:34 PM, Sean Paul  
> > > >>> wrote:
> > > >>> >
> > > >>> > Hi Dave,
> > > >>> > Here's this weeks pull, relatively small when you pull out the 
> > > >>> > trivial fixes.
> > > >>> >
> > > >>> > drm-misc-next-2018-02-28:
> > > >>> > drm-misc-next for 4.17:
> > > >>> >
> > > >>> > UAPI Changes:
> > > >>> >  Fix drm_color_ctm matrix docs to match usage and change the type to
> > > >>> >  __u64 make it obvious (Ville)
> > > >>>
> > > >>> Hi Dave,
> > > >>> Could you please hold off on pulling this? I'd like to sort out this
> > > >>> change a bit more. We're already using the __s64 in chrome, and not
> > > >>> explicitly sign-magnitude. I think it would be prudent to hash this
> > > >>> out a little more.
> > > >>>
> > > >>> https://cs.chromium.org/chromium/src/ui/ozone/platform/drm/gpu/drm_device.cc?l=161
> > > >>
> > > >> That code seems to be doing the exact same fun s.u63 math. This all 
> > > >> looks
> > > >> consistent to me.
> > > >
> > > > Hmm, yeah, I skimmed too quickly last week.
> > > >
> > > >>
> > > >> Now in hindsight ofc we've screwed up the uapi, but well can't fix that
> > > >> now again ...
> > > >
> > > > Yeah, I'm not convinced we should be changing the type. It's great to
> > > > clarify the documentation to let userspace know it's sign-magnitude,
> > > > but changing the type in-flight with users seems wrong.
> > > 
> > > But everyone must do unsigned bit ops to get this right, the s64 is
> > > completely meaningless at best, and very likely will confuse someone.
> > 
> > It's definitely a good change to clarify the usage of the field, I'm not 
> > arguing
> > against that.
> > 
> > > What do we benefit by not changing it? 
> > 
> > In the kernel, nothing. However changing uapi structs out from under 
> > userspace
> > requires userspace updates. In order for that to happen, they need to be
> > aware of the change and coordinate its rollout kernel/libdrm/compositor. At
> > least in CrOS, Chrome people don't follow kernel changes, so they'll 
> > discover
> > this with a compiler warning (hopefully) and have to backtrack what 
> > happened.
> > 
> > Given that everybody seems to be using this struct correctly, what do we 
> > benefit
> > from changing it? Wouldn't a comment be sufficient? Perhaps a union of
> > __s64/__u64 would be less disruptive.
> 
> Umm. What exactly broke? The code behind your link even casts the final
> value to unsigned. So now the struct actually matches the code.

We haven't pulled the change back, so nothing has changed in cros. You're right
that the code already does the right thing. So perhaps I'm just tilting at
windmills here, but this type of churn seemed unsettling to me.

Sean

> 
> -- 
> Ville Syrjälä
> Intel OTC

-- 
Sean Paul, Software Engineer, Google / Chromium OS
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


  1   2   3   4   >