Re: [PATCH v7 4/5] drm/tidss: New driver for TI Keystone platform Display SubSystem

2020-01-20 Thread Benoit Parrot
resource(pdev, dispc->feat->ovr_name[i],
> +          >base_ovr[i]);
> + dev_dbg(dev, "%s: %u %s %d\n", __func__,
> + i, dispc->feat->ovr_name[i], r);

Same here.

> + if (r)
> + return r;
> +
> + r = dispc_iomap_resource(pdev, dispc->feat->vp_name[i],
> +  >base_vp[i]);
> + dev_dbg(dev, "%s: %u %s %d\n", __func__,
> + i, dispc->feat->vp_name[i], r);

And here.

But with or without this change

Reviewed-by: Benoit Parrot 

> + if (r)
> + return r;
> +
> + clk = devm_clk_get(dev, dispc->feat->vpclk_name[i]);
> + if (IS_ERR(clk)) {
> + dev_err(dev, "%s: Failed to get clk %s:%ld\n", __func__,
> + dispc->feat->vpclk_name[i], PTR_ERR(clk));
> + return PTR_ERR(clk);
> + }
> + dispc->vp_clk[i] = clk;
> +
> + gamma_table = devm_kmalloc_array(dev, gamma_size,
> +  sizeof(*gamma_table),
> +  GFP_KERNEL);
> + if (!gamma_table)
> + return -ENOMEM;
> + dispc->vp_data[i].gamma_table = gamma_table;
> + }
> +
> + if (feat->subrev == DISPC_AM65X) {
> + r = dispc_init_am65x_oldi_io_ctrl(dev, dispc);
> + if (r)
> + return r;
> + }
> +
> + dispc->fclk = devm_clk_get(dev, "fck");
> + if (IS_ERR(dispc->fclk)) {
> + dev_err(dev, "%s: Failed to get fclk: %ld\n",
> + __func__, PTR_ERR(dispc->fclk));
> + return PTR_ERR(dispc->fclk);
> + }
> + dev_dbg(dev, "DSS fclk %lu Hz\n", clk_get_rate(dispc->fclk));
> +
> + of_property_read_u32(dispc->dev->of_node, "max-memory-bandwidth",
> +  >memory_bandwidth_limit);
> +
> + tidss->dispc = dispc;
> +
> + return 0;
> +}
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v7 5/5] MAINTAINERS: add entry for tidss

2020-01-20 Thread Benoit Parrot
Jyri Sarha  wrote on Thu [2020-Jan-16 23:06:00 +0200]:
> Add entry for tidss DRM driver.
> 
> Version history:
> 
> v2: no change
> 
> v3: - Move tidss entry after omapdrm
> - Add "T: git git://anongit.freedesktop.org/drm/drm-misc"
> 
> v4: no change
> 
> v5: no change
> 
> v6: no change
> 
> v7: no change
> 
> Signed-off-by: Jyri Sarha 

> ---
>  MAINTAINERS | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index aa9add598b7d..d8f65dc1dde8 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5630,6 +5630,17 @@ S: Maintained
>  F:   drivers/gpu/drm/omapdrm/
>  F:   Documentation/devicetree/bindings/display/ti/
>  
> +DRM DRIVERS FOR TI KEYSTONE
> +M:   Jyri Sarha 
> +M:   Tomi Valkeinen 
> +L:   dri-devel@lists.freedesktop.org
> +S:   Maintained
> +F:   drivers/gpu/drm/tidss/
> +F:   Documentation/devicetree/bindings/display/ti/ti,k2g-dss.yaml
> +F:   Documentation/devicetree/bindings/display/ti/ti,am65x-dss.yaml
> +F:   Documentation/devicetree/bindings/display/ti/ti,j721e-dss.yaml
> +T:   git git://anongit.freedesktop.org/drm/drm-misc
> +
>  DRM DRIVERS FOR V3D
>  M:   Eric Anholt 
>  S:   Supported
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v5 5/5] MAINTAINERS: add entry for tidss

2020-01-13 Thread Benoit Parrot
Jyri Sarha  wrote on Fri [2019-Dec-20 17:55:13 +0200]:
> Add entry for tidss DRM driver.
> 
> Version history:
> 
> v2: no change
> 
> v3: - Move tidss entry after omapdrm
> - Add "T: git git://anongit.freedesktop.org/drm/drm-misc"
> 
> v4: no change
> 
> v5: no change
> 
> Signed-off-by: Jyri Sarha 

Reviewed-by: Benoit Parrot 

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


Re: [PATCH v5 2/5] dt-bindings: display: ti, am65x-dss: Add dt-schema yaml binding

2020-01-13 Thread Benoit Parrot
Jyri Sarha  wrote on Fri [2019-Dec-20 17:55:10 +0200]:
> Add dt-schema yaml bindig for AM65x DSS, AM65x version TI Keystone
> Display SubSystem.
> 
> Version history:
> 
> v2: no change
> 
> v3: - Add ports node
> - use allOf in ti,am65x-oldi-io-ctrl to add both $ref and maxItems
> - Add includes to dts example
> - reindent dts example
> 
> v4: - Add descriptions to reg and clocks properties
> - Remove minItems when its value is the same as maxItems value
> 
> v5: - itemize reg and clocks properties' descriptions
> 
> Signed-off-by: Jyri Sarha 

Reviewed-by: Benoit Parrot 

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


Re: [PATCH v5 1/5] dt-bindings: display: ti,k2g-dss: Add dt-schema yaml binding

2020-01-13 Thread Benoit Parrot
Jyri Sarha  wrote on Fri [2019-Dec-20 17:55:09 +0200]:
> Add dt-schema yaml bindig for K2G DSS, an ultra-light version of TI
> Keystone Display SubSystem.
> 
> Version history:
> 
> v2: no change
> 
> v3: - Add ports node
> - Add includes to dts example
> - reindent dts example
> 
> v4: - Add descriptions to reg and clocks properties
> - Remove minItems when its value is the same as maxItems value
> - Remove ports node
> 
> v5: - itemize reg and clocks properties' descriptions
> 
> Signed-off-by: Jyri Sarha 

Reviewed-by: Benoit Parrot 

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


Re: [PATCH v5 4/5] drm/tidss: New driver for TI Keystone platform Display SubSystem

2020-01-13 Thread Benoit Parrot
Jyri Sarha  wrote on Fri [2019-Dec-20 17:55:12 +0200]:
> This patch adds a new DRM driver for Texas Instruments DSS IPs used on
> Texas Instruments Keystone K2G, AM65x, and J721e SoCs. The new DSS IP is
> a major change to the older DSS IP versions, which are supported by
> the omapdrm driver. While on higher level the Keystone DSS resembles
> the older DSS versions, the registers are completely different and the
> internal pipelines differ a lot.
> 
> DSS IP found on K2G is an "ultra-light" version, and has only a single
> plane and a single output. The Keystone 3 DSS IPs are found on AM65x
> and J721E SoCs. AM65x DSS has two video ports, one full video plane,
> and another "lite" plane without scaling support. J721E has 4 video
> ports, 2 video planes and 2 lite planes. AM65x DSS has also integrated
> OLDI (LVDS) output.
> 
> Version history:
> 
> v2: - rebased on top of drm-next-2019-11-27
> - sort all include lines in all files
> - remove all include 
> - remove select "select VIDEOMODE_HELPERS"
> - call dispc_vp_setup() later in tidss_crtc_atomic_flush() (there is no
>   to call it in new modeset case as it is also called in vp_enable())
> - change probe sequence and drm_device allocation (follow example in
>   drm_drv.c)
> - use __maybe_unused instead of #ifdef for pm functions
> - remove "struct drm_fbdev_cma *fbdev;" from driver data
> - check panel connector type before connecting it
> 
> v3: no change
> 
> v4: no change
> 
> v5: - remove fifo underflow irq handling, it is not an error and
>   it should be used for debug purposes only
> - memory tuning, prefetch plane fifo up to high-threshold value to
>   minimize possibility of underflows.
> 
> Co-developed-by: Tomi Valkeinen 
> Signed-off-by: Jyri Sarha 

Reviewed-by: Benoit Parrot 

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


Re: [PATCH v5 3/5] dt-bindings: display: ti, j721e-dss: Add dt-schema yaml binding

2020-01-13 Thread Benoit Parrot
Jyri Sarha  wrote on Fri [2019-Dec-20 17:55:11 +0200]:
> Add dt-schema yaml bindig for J721E DSS, J721E version TI Keystone
> Display SubSystem.
> 
> Version history:
> 
> v2: no change
> 
> v3: - reg-names: "wp" -> "wb"
> - Add ports node
> - Add includes to dts example
> - reindent dts example
> 
> v4: - Add descriptions to reg, clocks, and interrups properties
> - Remove minItems when its value is the same as maxItems value
> 
> v5: - itemize reg, clocks and interrupts properties' descriptions
> - there is no "vp" reg-name, only "wb" for write back
> 
> Signed-off-by: Jyri Sarha 

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


Re: [Patch 1/1] drm/atomic: integrate private objects with suspend/resume helpers

2019-03-15 Thread Benoit Parrot
Daniel Vetter  wrote on Fri [2019-Mar-15 11:50:57 +0100]:
> On Thu, Mar 14, 2019 at 08:44:45AM -0500, Benoit Parrot wrote:
> > During a suspend cycle the atomic state is saved to be used during the
> > restore cycle.
> > 
> > However the current state duplication logic does not duplicate private
> > objects. This leads to state inconsistencies at resume time.
> > 
> > With private objects modeset lock now integrated, we can make sure that
> > private object state are properly saved and restored.
> > 
> > Signed-off-by: Benoit Parrot 
> 
> Why do you need this? We're doing a full atomic_check, and your
> atomic_check should be pulling in any private state objects and
> recomputing their states. This smells like papering over a driver bug.

I have not seen any atomic_check called during the suspend duplicate
helper. And you are correct normally the private_object state in my case
would get pulled in during a plane atomic_check but that does not happen
here in this step.

Why wouldn't we save all the "state" artifacts so that the whole atomic
state is consistent?

Benoit

> 
> The duplicate helpers should only need to duplicate the uapi-relevant
> states, i.e. connector/crtc/planes.
> -Daniel
> 
> > ---
> >  drivers/gpu/drm/drm_atomic_helper.c | 16 
> >  1 file changed, 16 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> > b/drivers/gpu/drm/drm_atomic_helper.c
> > index 540a77a2ade9..b108021cc092 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -3189,6 +3189,7 @@ drm_atomic_helper_duplicate_state(struct drm_device 
> > *dev,
> > struct drm_connector_list_iter conn_iter;
> > struct drm_plane *plane;
> > struct drm_crtc *crtc;
> > +   struct drm_private_obj *privobj;
> > int err = 0;
> >  
> > state = drm_atomic_state_alloc(dev);
> > @@ -3218,6 +3219,16 @@ drm_atomic_helper_duplicate_state(struct drm_device 
> > *dev,
> > }
> > }
> >  
> > +   drm_for_each_privobj(privobj, dev) {
> > +   struct drm_private_state *priv_state;
> > +
> > +   priv_state = drm_atomic_get_private_obj_state(state, privobj);
> > +   if (IS_ERR(priv_state)) {
> > +   err = PTR_ERR(priv_state);
> > +   goto free;
> > +   }
> > +   }
> > +
> > drm_connector_list_iter_begin(dev, _iter);
> > drm_for_each_connector_iter(conn, _iter) {
> > struct drm_connector_state *conn_state;
> > @@ -3325,12 +3336,17 @@ int 
> > drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
> > struct drm_connector_state *new_conn_state;
> > struct drm_crtc *crtc;
> > struct drm_crtc_state *new_crtc_state;
> > +   struct drm_private_obj *privobj;
> > +   struct drm_private_state *new_priv_state;
> >  
> > state->acquire_ctx = ctx;
> >  
> > for_each_new_plane_in_state(state, plane, new_plane_state, i)
> > state->planes[i].old_state = plane->state;
> >  
> > +   for_each_new_private_obj_in_state(state, privobj, new_priv_state, i)
> > +   state->private_objs[i].old_state = privobj->state;
> > +
> > for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
> > state->crtcs[i].old_state = crtc->state;
> >  
> > -- 
> > 2.17.1
> > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [Patch 1/1] drm/atomic: integrate private objects with suspend/resume helpers

2019-03-14 Thread Benoit Parrot
Ville Syrjälä  wrote on Thu [2019-Mar-14 
17:31:29 +0200]:
> On Thu, Mar 14, 2019 at 08:44:45AM -0500, Benoit Parrot wrote:
> > During a suspend cycle the atomic state is saved to be used during the
> > restore cycle.
> > 
> > However the current state duplication logic does not duplicate private
> > objects. This leads to state inconsistencies at resume time.
> > 
> > With private objects modeset lock now integrated, we can make sure that
> > private object state are properly saved and restored.
> > 
> > Signed-off-by: Benoit Parrot 
> > ---
> >  drivers/gpu/drm/drm_atomic_helper.c | 16 
> >  1 file changed, 16 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> > b/drivers/gpu/drm/drm_atomic_helper.c
> > index 540a77a2ade9..b108021cc092 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -3189,6 +3189,7 @@ drm_atomic_helper_duplicate_state(struct drm_device 
> > *dev,
> > struct drm_connector_list_iter conn_iter;
> > struct drm_plane *plane;
> > struct drm_crtc *crtc;
> > +   struct drm_private_obj *privobj;
> > int err = 0;
> >  
> > state = drm_atomic_state_alloc(dev);
> > @@ -3218,6 +3219,16 @@ drm_atomic_helper_duplicate_state(struct drm_device 
> > *dev,
> > }
> > }
> >  
> > +   drm_for_each_privobj(privobj, dev) {
> > +   struct drm_private_state *priv_state;
> > +
> > +   priv_state = drm_atomic_get_private_obj_state(state, privobj);
> > +   if (IS_ERR(priv_state)) {
> > +   err = PTR_ERR(priv_state);
> > +   goto free;
> > +   }
> > +   }
> > +
> > drm_connector_list_iter_begin(dev, _iter);
> > drm_for_each_connector_iter(conn, _iter) {
> > struct drm_connector_state *conn_state;
> > @@ -3325,12 +3336,17 @@ int 
> > drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
> > struct drm_connector_state *new_conn_state;
> > struct drm_crtc *crtc;
> > struct drm_crtc_state *new_crtc_state;
> > +   struct drm_private_obj *privobj;
> > +   struct drm_private_state *new_priv_state;
> >  
> > state->acquire_ctx = ctx;
> >  
> > for_each_new_plane_in_state(state, plane, new_plane_state, i)
> > state->planes[i].old_state = plane->state;
> >  
> > +   for_each_new_private_obj_in_state(state, privobj, new_priv_state, i)
> > +   state->private_objs[i].old_state = privobj->state;
> > +
> > for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
> > state->crtcs[i].old_state = crtc->state;
> 
> Random order between crtc vs. plane vs. connector vs. priv is tickling
> my ocd nerve a bit.

These loops are independent from each other.
And even without this patch the order is different between
drm_atomic_helper_duplicate_state() and
drm_atomic_helper_commit_duplicated_state(). :)

Benoit

> 
> Otherwise looks sensible to me.
> Reviewed-by: Ville Syrjälä 
> 
> >  
> > -- 
> > 2.17.1
> > 
> > ___
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Ville Syrjälä
> Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Patch 1/1] drm/atomic: integrate private objects with suspend/resume helpers

2019-03-14 Thread Benoit Parrot
During a suspend cycle the atomic state is saved to be used during the
restore cycle.

However the current state duplication logic does not duplicate private
objects. This leads to state inconsistencies at resume time.

With private objects modeset lock now integrated, we can make sure that
private object state are properly saved and restored.

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/drm_atomic_helper.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 540a77a2ade9..b108021cc092 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3189,6 +3189,7 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
struct drm_connector_list_iter conn_iter;
struct drm_plane *plane;
struct drm_crtc *crtc;
+   struct drm_private_obj *privobj;
int err = 0;
 
state = drm_atomic_state_alloc(dev);
@@ -3218,6 +3219,16 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
}
}
 
+   drm_for_each_privobj(privobj, dev) {
+   struct drm_private_state *priv_state;
+
+   priv_state = drm_atomic_get_private_obj_state(state, privobj);
+   if (IS_ERR(priv_state)) {
+   err = PTR_ERR(priv_state);
+   goto free;
+   }
+   }
+
drm_connector_list_iter_begin(dev, _iter);
drm_for_each_connector_iter(conn, _iter) {
struct drm_connector_state *conn_state;
@@ -3325,12 +3336,17 @@ int drm_atomic_helper_commit_duplicated_state(struct 
drm_atomic_state *state,
struct drm_connector_state *new_conn_state;
struct drm_crtc *crtc;
struct drm_crtc_state *new_crtc_state;
+   struct drm_private_obj *privobj;
+   struct drm_private_state *new_priv_state;
 
state->acquire_ctx = ctx;
 
for_each_new_plane_in_state(state, plane, new_plane_state, i)
state->planes[i].old_state = plane->state;
 
+   for_each_new_private_obj_in_state(state, privobj, new_priv_state, i)
+   state->private_objs[i].old_state = privobj->state;
+
for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
state->crtcs[i].old_state = crtc->state;
 
-- 
2.17.1

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

Re: [Patch v4 0/8] drm/omap: Add virtual-planes support

2018-11-19 Thread Benoit Parrot
Ping.

Benoit

Benoit Parrot  wrote on Fri [2018-Oct-12 15:16:55 -0500]:
> This patch series adds virtual-plane support to omapdrm driver to allow the 
> use
> of display wider than 2048 pixels.
> 
> In order to do so we introduce the concept of hw_overlay which can then be
> dynamically allocated to a plane. When the requested output width exceed what
> be supported by one overlay a second is then allocated if possible to handle
> display wider then 2048.
> 
> This series replaces an earlier series which was DT based and using statically
> allocated resources. 
> 
> This implementation is inspired from the work done in msm/disp/mdp5
> driver.
> 
> Benoit Parrot (8):
>   drm/omap: Add ability to check if requested plane modes can be
> supported
>   drm/omap: Add ovl checking funcs to dispc_ops
>   drm/omap: introduce omap_hw_overlay
>   drm/omap: omap_plane: subclass drm_plane_state
>   drm/omap: Add global state as a private atomic object
>   drm/omap: dynamically assign hw overlays to planes
>   drm/omap: add plane_atomic_print_state support
>   drm/omap: Add a 'right overlay' to plane state
> 
>  drivers/gpu/drm/omapdrm/Makefile   |   1 +
>  drivers/gpu/drm/omapdrm/dss/dispc.c|  32 +++
>  drivers/gpu/drm/omapdrm/dss/omapdss.h  |   6 +
>  drivers/gpu/drm/omapdrm/omap_drv.c | 196 -
>  drivers/gpu/drm/omapdrm/omap_drv.h |  30 +++
>  drivers/gpu/drm/omapdrm/omap_fb.c  |  33 ++-
>  drivers/gpu/drm/omapdrm/omap_fb.h  |   4 +-
>  drivers/gpu/drm/omapdrm/omap_overlay.c | 257 ++
>  drivers/gpu/drm/omapdrm/omap_overlay.h |  41 
>  drivers/gpu/drm/omapdrm/omap_plane.c   | 374 
> -
>  drivers/gpu/drm/omapdrm/omap_plane.h   |   1 +
>  11 files changed, 922 insertions(+), 53 deletions(-)
>  create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.c
>  create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.h
> 
> -- 
> 2.9.0
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Patch v4 5/8] drm/omap: Add global state as a private atomic object

2018-10-18 Thread Benoit Parrot
Daniel Vetter  wrote on Tue [2018-Oct-16 14:29:46 +0200]:
> On Fri, Oct 12, 2018 at 03:17:00PM -0500, Benoit Parrot wrote:
> > Global shared resources (like hw overlays) for omapdrm are implemented
> > as a part of atomic state using the drm_private_obj infrastructure
> > available in the atomic core.
> > 
> > omap_global_state is introduced as a drm atomic private object. The two
> > funcs omap_get_global_state() and omap_get_existing_global_state() are
> > the two variants that will be used to access omap_global_state.
> > 
> > Signed-off-by: Benoit Parrot 
> > ---
> >  drivers/gpu/drm/omapdrm/omap_drv.c | 97 
> > +-
> >  drivers/gpu/drm/omapdrm/omap_drv.h | 23 +
> >  2 files changed, 119 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
> > b/drivers/gpu/drm/omapdrm/omap_drv.c
> > index 2921cc90f2d8..94658ec79c76 100644
> > --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> > +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> > @@ -129,6 +129,94 @@ static const struct drm_mode_config_funcs 
> > omap_mode_config_funcs = {
> > .atomic_commit = drm_atomic_helper_commit,
> >  };
> >  
> > +/* Global/shared object state funcs */
> > +
> > +/*
> > + * This is a helper that returns the private state currently in operation.
> > + * Note that this would return the "old_state" if called in the atomic 
> > check
> > + * path, and the "new_state" after the atomic swap has been done.
> > + */
> > +struct omap_global_state *
> > +omap_get_existing_global_state(struct omap_drm_private *priv)
> > +{
> > +   return to_omap_global_state(priv->glob_obj.state);
> > +}
> > +
> > +/*
> > + * This acquires the modeset lock set aside for global state, creates
> > + * a new duplicated private object state.
> > + */
> > +struct omap_global_state *__must_check
> > +omap_get_global_state(struct drm_atomic_state *s)
> > +{
> > +   struct omap_drm_private *priv = s->dev->dev_private;
> > +   struct drm_private_state *priv_state;
> > +   int ret;
> > +
> > +   if (!drm_modeset_is_locked(>glob_obj_lock)) {
> > +   ret = drm_modeset_lock(>glob_obj_lock, s->acquire_ctx);
> > +   if (ret) {
> > +   DBG("getting priv->glob_obj_lock (%p) failed %d",
> > +   >glob_obj_lock, ret);
> > +   return ERR_PTR(ret);
> > +   }
> > +   }
> > +
> > +   priv_state = drm_atomic_get_private_obj_state(s, >glob_obj);
> 
> One of the refactors I had in mind (and which would be possible now that
> private state structs are implemented as properly structs, instead of void
> * pointers): Add a drm_modeset_lock to drm_private_obj and avoid having to
> duplicate that over all implementations. Not everyone wants a per-obj
> lock, but no one will be hurt by having a per-obj lock - drm_modeset_lock
> is very extensible in that way. And we could drop the custom locking code
> everyone has to roll themselves.

Thanks for the feedback. I was wondering the same when I was "duplicating"
this code. I will take this under advisement, but I would probably see that
as a separate patch set, either before or after this one :) 

Benoit

> 
> Just a drive-by refactor idea.
> -Daniel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Patch v4 5/8] drm/omap: Add global state as a private atomic object

2018-10-12 Thread Benoit Parrot
Global shared resources (like hw overlays) for omapdrm are implemented
as a part of atomic state using the drm_private_obj infrastructure
available in the atomic core.

omap_global_state is introduced as a drm atomic private object. The two
funcs omap_get_global_state() and omap_get_existing_global_state() are
the two variants that will be used to access omap_global_state.

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 97 +-
 drivers/gpu/drm/omapdrm/omap_drv.h | 23 +
 2 files changed, 119 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 2921cc90f2d8..94658ec79c76 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -129,6 +129,94 @@ static const struct drm_mode_config_funcs 
omap_mode_config_funcs = {
.atomic_commit = drm_atomic_helper_commit,
 };
 
+/* Global/shared object state funcs */
+
+/*
+ * This is a helper that returns the private state currently in operation.
+ * Note that this would return the "old_state" if called in the atomic check
+ * path, and the "new_state" after the atomic swap has been done.
+ */
+struct omap_global_state *
+omap_get_existing_global_state(struct omap_drm_private *priv)
+{
+   return to_omap_global_state(priv->glob_obj.state);
+}
+
+/*
+ * This acquires the modeset lock set aside for global state, creates
+ * a new duplicated private object state.
+ */
+struct omap_global_state *__must_check
+omap_get_global_state(struct drm_atomic_state *s)
+{
+   struct omap_drm_private *priv = s->dev->dev_private;
+   struct drm_private_state *priv_state;
+   int ret;
+
+   if (!drm_modeset_is_locked(>glob_obj_lock)) {
+   ret = drm_modeset_lock(>glob_obj_lock, s->acquire_ctx);
+   if (ret) {
+   DBG("getting priv->glob_obj_lock (%p) failed %d",
+   >glob_obj_lock, ret);
+   return ERR_PTR(ret);
+   }
+   }
+
+   priv_state = drm_atomic_get_private_obj_state(s, >glob_obj);
+   if (IS_ERR(priv_state))
+   return ERR_CAST(priv_state);
+
+   return to_omap_global_state(priv_state);
+}
+
+static struct drm_private_state *
+omap_global_duplicate_state(struct drm_private_obj *obj)
+{
+   struct omap_global_state *state;
+
+   state = kmemdup(obj->state, sizeof(*state), GFP_KERNEL);
+   if (!state)
+   return NULL;
+
+   __drm_atomic_helper_private_obj_duplicate_state(obj, >base);
+
+   return >base;
+}
+
+static void omap_global_destroy_state(struct drm_private_obj *obj,
+ struct drm_private_state *state)
+{
+   struct omap_global_state *omap_state = to_omap_global_state(state);
+
+   kfree(omap_state);
+}
+
+static const struct drm_private_state_funcs omap_global_state_funcs = {
+   .atomic_duplicate_state = omap_global_duplicate_state,
+   .atomic_destroy_state = omap_global_destroy_state,
+};
+
+static int omap_global_obj_init(struct omap_drm_private *priv)
+{
+   struct omap_global_state *state;
+
+   drm_modeset_lock_init(>glob_obj_lock);
+
+   state = kzalloc(sizeof(*state), GFP_KERNEL);
+   if (!state)
+   return -ENOMEM;
+
+   drm_atomic_private_obj_init(>glob_obj, >base,
+   _global_state_funcs);
+   return 0;
+}
+
+static void omap_global_obj_fini(struct omap_drm_private *priv)
+{
+   drm_atomic_private_obj_fini(>glob_obj);
+   drm_modeset_lock_fini(>glob_obj_lock);
+}
+
 static void omap_disconnect_pipelines(struct drm_device *ddev)
 {
struct omap_drm_private *priv = ddev->dev_private;
@@ -569,10 +657,14 @@ static int omapdrm_init(struct omap_drm_private *priv, 
struct device *dev)
 
omap_gem_init(ddev);
 
-   ret = omap_hwoverlays_init(priv);
+   ret = omap_global_obj_init(priv);
if (ret)
goto err_gem_deinit;
 
+   ret = omap_hwoverlays_init(priv);
+   if (ret)
+   goto err_free_priv_obj;
+
ret = omap_modeset_init(ddev);
if (ret) {
dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret);
@@ -612,6 +704,8 @@ 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_priv_obj:
+   omap_global_obj_fini(priv);
 err_free_overlays:
omap_hwoverlays_destroy(priv);
 err_gem_deinit:
@@ -644,6 +738,7 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)
omap_drm_irq_uninstall(ddev);
omap_gem_deinit(ddev);
 
+   omap_global_obj_fini(priv);
omap_hwoverlays_destroy(priv);
 
destroy_workqueue(priv->wq);
diff --git a/drive

[Patch v4 7/8] drm/omap: add plane_atomic_print_state support

2018-10-12 Thread Benoit Parrot
Now that we added specific item to our subclassed drm_plane_state
we can add omap_plane_atomic_print_state() helper to dump out our own
driver specific plane state.

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/omapdrm/omap_plane.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c 
b/drivers/gpu/drm/omapdrm/omap_plane.c
index 224520348fc5..116071982a0e 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -348,6 +348,23 @@ omap_plane_atomic_duplicate_state(struct drm_plane *plane)
return >base;
 }
 
+static void omap_plane_atomic_print_state(struct drm_printer *p,
+ const struct drm_plane_state *state)
+{
+   struct omap_plane_state *omap_state = to_omap_plane_state(state);
+
+   drm_printf(p, "\toverlay=%s\n", omap_state->overlay ?
+   omap_state->overlay->name : "(null)");
+   if (omap_state->overlay) {
+   drm_printf(p, "\t\tidx=%d\n", omap_state->overlay->idx);
+   drm_printf(p, "\t\toverlay_id=%d\n",
+  omap_state->overlay->overlay_id);
+   drm_printf(p, "\t\tcaps=0x%x\n", omap_state->overlay->caps);
+   drm_printf(p, "\t\tpossible_crtcs=0x%x\n",
+  omap_state->overlay->possible_crtcs);
+   }
+}
+
 static int omap_plane_atomic_set_property(struct drm_plane *plane,
  struct drm_plane_state *state,
  struct drm_property *property,
@@ -387,6 +404,7 @@ static const struct drm_plane_funcs omap_plane_funcs = {
.atomic_destroy_state = omap_plane_atomic_destroy_state,
.atomic_set_property = omap_plane_atomic_set_property,
.atomic_get_property = omap_plane_atomic_get_property,
+   .atomic_print_state = omap_plane_atomic_print_state,
 };
 
 static const char *plane_id_to_name[] = {
-- 
2.9.0

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


[Patch v4 0/8] drm/omap: Add virtual-planes support

2018-10-12 Thread Benoit Parrot
This patch series adds virtual-plane support to omapdrm driver to allow the use
of display wider than 2048 pixels.

In order to do so we introduce the concept of hw_overlay which can then be
dynamically allocated to a plane. When the requested output width exceed what
be supported by one overlay a second is then allocated if possible to handle
display wider then 2048.

This series replaces an earlier series which was DT based and using statically
allocated resources. 

This implementation is inspired from the work done in msm/disp/mdp5
driver.

Benoit Parrot (8):
  drm/omap: Add ability to check if requested plane modes can be
supported
  drm/omap: Add ovl checking funcs to dispc_ops
  drm/omap: introduce omap_hw_overlay
  drm/omap: omap_plane: subclass drm_plane_state
  drm/omap: Add global state as a private atomic object
  drm/omap: dynamically assign hw overlays to planes
  drm/omap: add plane_atomic_print_state support
  drm/omap: Add a 'right overlay' to plane state

 drivers/gpu/drm/omapdrm/Makefile   |   1 +
 drivers/gpu/drm/omapdrm/dss/dispc.c|  32 +++
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |   6 +
 drivers/gpu/drm/omapdrm/omap_drv.c | 196 -
 drivers/gpu/drm/omapdrm/omap_drv.h |  30 +++
 drivers/gpu/drm/omapdrm/omap_fb.c  |  33 ++-
 drivers/gpu/drm/omapdrm/omap_fb.h  |   4 +-
 drivers/gpu/drm/omapdrm/omap_overlay.c | 257 ++
 drivers/gpu/drm/omapdrm/omap_overlay.h |  41 
 drivers/gpu/drm/omapdrm/omap_plane.c   | 374 -
 drivers/gpu/drm/omapdrm/omap_plane.h   |   1 +
 11 files changed, 922 insertions(+), 53 deletions(-)
 create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.c
 create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.h

-- 
2.9.0

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


[Patch v4 1/8] drm/omap: Add ability to check if requested plane modes can be supported

2018-10-12 Thread Benoit Parrot
We currently assume that an overlay has the same maximum width and
maximum height as the overlay manager. This assumption is incorrect. On
some variants the overlay manager maximum width is twice the maximum
width that the overlay can handle. We need to add the appropriate data
per variant as well as export a helper function to retrieve the data so
check can be made dynamically in omap_plane_atomic_check().

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 24 
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  2 ++
 drivers/gpu/drm/omapdrm/omap_plane.c  | 14 ++
 3 files changed, 40 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index fe0b5f6ede72..70c3e3353947 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -103,6 +103,8 @@ struct dispc_features {
u8 mgr_height_start;
u16 mgr_width_max;
u16 mgr_height_max;
+   u16 ovl_width_max;
+   u16 ovl_height_max;
unsigned long max_lcd_pclk;
unsigned long max_tv_pclk;
unsigned int max_downscale;
@@ -2596,6 +2598,13 @@ static int dispc_ovl_calc_scaling(struct dispc_device 
*dispc,
return 0;
 }
 
+static void dispc_ovl_get_max_size(struct dispc_device *dispc,
+  u16 *width, u16 *height)
+{
+   *width = dispc->feat->ovl_width_max;
+   *height = dispc->feat->ovl_height_max;
+}
+
 static int dispc_ovl_setup_common(struct dispc_device *dispc,
  enum omap_plane_id plane,
  enum omap_overlay_caps caps,
@@ -4247,6 +4256,8 @@ static const struct dispc_features omap24xx_dispc_feats = 
{
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   6650,
.max_downscale  =   2,
/*
@@ -4284,6 +4295,8 @@ static const struct dispc_features 
omap34xx_rev1_0_dispc_feats = {
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17300,
.max_tv_pclk=   5900,
.max_downscale  =   4,
@@ -4318,6 +4331,8 @@ static const struct dispc_features 
omap34xx_rev3_0_dispc_feats = {
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17300,
.max_tv_pclk=   5900,
.max_downscale  =   4,
@@ -4352,6 +4367,8 @@ static const struct dispc_features omap36xx_dispc_feats = 
{
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17300,
.max_tv_pclk=   5900,
.max_downscale  =   4,
@@ -4386,6 +4403,8 @@ static const struct dispc_features am43xx_dispc_feats = {
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17300,
.max_tv_pclk=   5900,
.max_downscale  =   4,
@@ -4420,6 +4439,8 @@ static const struct dispc_features omap44xx_dispc_feats = 
{
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17000,
.max_tv_pclk=   185625000,
.max_downscale  =   4,
@@ -4459,6 +4480,8 @@ static const struct dispc_features omap54xx_dispc_feats = 
{
.mgr_height_start   =   27,
.mgr_width_max  =   4096,
.mgr_height_max =   4096,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   4096,
.max_lcd_pclk   =   17000,
.max_tv_pclk=   19200,
.max_downscale  =   4,
@@ -4734,6 +4757,7 @@ static const struct dispc_ops dispc_ops = {
.ovl_enable = dispc_ovl_enable,
.ovl_setup = dis

[Patch v4 3/8] drm/omap: introduce omap_hw_overlay

2018-10-12 Thread Benoit Parrot
Split out the hardware overlay specifics from omap_plane.
To start, the hw overlays are statically assigned to planes.

The goal is to eventually assign hw overlays dynamically to planes
during plane->atomic_check() based on requested caps (scaling, YUV,
etc). And then perform hw overlay re-assignment if required.

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/omapdrm/Makefile   |  1 +
 drivers/gpu/drm/omapdrm/omap_drv.c | 10 +++-
 drivers/gpu/drm/omapdrm/omap_drv.h |  4 ++
 drivers/gpu/drm/omapdrm/omap_overlay.c | 87 ++
 drivers/gpu/drm/omapdrm/omap_overlay.h | 31 
 drivers/gpu/drm/omapdrm/omap_plane.c   | 47 +-
 6 files changed, 156 insertions(+), 24 deletions(-)
 create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.c
 create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.h

diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
index f115253115c5..800dfd035360 100644
--- a/drivers/gpu/drm/omapdrm/Makefile
+++ b/drivers/gpu/drm/omapdrm/Makefile
@@ -12,6 +12,7 @@ omapdrm-y := omap_drv.o \
omap_debugfs.o \
omap_crtc.o \
omap_plane.o \
+   omap_overlay.o \
omap_encoder.o \
omap_connector.o \
omap_fb.o \
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 5e67d58cbc28..2921cc90f2d8 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -569,10 +569,14 @@ static int omapdrm_init(struct omap_drm_private *priv, 
struct device *dev)
 
omap_gem_init(ddev);
 
+   ret = omap_hwoverlays_init(priv);
+   if (ret)
+   goto err_gem_deinit;
+
ret = omap_modeset_init(ddev);
if (ret) {
dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret);
-   goto err_gem_deinit;
+   goto err_free_overlays;
}
 
/* Initialize vblank handling, start with all CRTCs disabled. */
@@ -608,6 +612,8 @@ 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_overlays:
+   omap_hwoverlays_destroy(priv);
 err_gem_deinit:
omap_gem_deinit(ddev);
destroy_workqueue(priv->wq);
@@ -638,6 +644,8 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)
omap_drm_irq_uninstall(ddev);
omap_gem_deinit(ddev);
 
+   omap_hwoverlays_destroy(priv);
+
destroy_workqueue(priv->wq);
 
omap_disconnect_pipelines(ddev);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h 
b/drivers/gpu/drm/omapdrm/omap_drv.h
index bd7f2c227a25..929f04e7cc3b 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -37,6 +37,7 @@
 #include "omap_gem.h"
 #include "omap_irq.h"
 #include "omap_plane.h"
+#include "omap_overlay.h"
 
 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
 #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt, ##__VA_ARGS__) /* verbose debug */
@@ -69,6 +70,9 @@ struct omap_drm_private {
unsigned int num_planes;
struct drm_plane *planes[8];
 
+   unsigned int num_ovls;
+   struct omap_hw_overlay *overlays[8];
+
struct drm_fb_helper *fbdev;
 
struct workqueue_struct *wq;
diff --git a/drivers/gpu/drm/omapdrm/omap_overlay.c 
b/drivers/gpu/drm/omapdrm/omap_overlay.c
new file mode 100644
index ..7a09b0aa823a
--- /dev/null
+++ b/drivers/gpu/drm/omapdrm/omap_overlay.c
@@ -0,0 +1,87 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Texas Instruments Incorporated -  http://www.ti.com/
+ * Author: Benoit Parrot, 
+ */
+
+#include 
+#include 
+#include 
+
+#include "omap_dmm_tiler.h"
+#include "omap_drv.h"
+
+/*
+ * overlay funcs
+ */
+static const char * const overlay_id_to_name[] = {
+   [OMAP_DSS_GFX] = "gfx",
+   [OMAP_DSS_VIDEO1] = "vid1",
+   [OMAP_DSS_VIDEO2] = "vid2",
+   [OMAP_DSS_VIDEO3] = "vid3",
+};
+
+static void omap_overlay_destroy(struct omap_hw_overlay *overlay)
+{
+   kfree(overlay);
+}
+
+static struct omap_hw_overlay *omap_overlay_init(enum omap_plane_id overlay_id,
+enum omap_overlay_caps caps)
+{
+   struct omap_hw_overlay *overlay;
+
+   overlay = kzalloc(sizeof(*overlay), GFP_KERNEL);
+   if (!overlay)
+   return ERR_PTR(-ENOMEM);
+
+   overlay->name = overlay_id_to_name[overlay_id];
+   overlay->overlay_id = overlay_id;
+   overlay->caps = caps;
+   /*
+* When this is called priv->num_crtcs is not known yet.
+* Use a safe mask value to start with, it will get updated to the
+* proper value after the first use.
+*/
+   overlay->possible_crtcs = 0x

[Patch v4 4/8] drm/omap: omap_plane: subclass drm_plane_state

2018-10-12 Thread Benoit Parrot
In preparation to add omap plane state specific extensions we need to
subclass drm_plane_state and add the relevant helpers.

The addition of specific extension will be done separately.

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/omapdrm/omap_plane.c | 48 +---
 1 file changed, 44 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c 
b/drivers/gpu/drm/omapdrm/omap_plane.c
index 26c2c78d020f..b0e60119c0a1 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -26,6 +26,12 @@
  * plane funcs
  */
 
+#define to_omap_plane_state(x) container_of(x, struct omap_plane_state, base)
+
+struct omap_plane_state {
+   struct drm_plane_state base;
+};
+
 #define to_omap_plane(x) container_of(x, struct omap_plane, base)
 
 struct omap_plane {
@@ -202,14 +208,29 @@ void omap_plane_install_properties(struct drm_plane 
*plane,
drm_object_attach_property(obj, priv->zorder_prop, 0);
 }
 
+static void omap_plane_atomic_destroy_state(struct drm_plane *plane,
+   struct drm_plane_state *state)
+{
+   __drm_atomic_helper_plane_destroy_state(state);
+   kfree(to_omap_plane_state(state));
+}
+
 static void omap_plane_reset(struct drm_plane *plane)
 {
struct omap_plane *omap_plane = to_omap_plane(plane);
+   struct omap_plane_state *omap_state;
 
-   drm_atomic_helper_plane_reset(plane);
-   if (!plane->state)
+   if (plane->state)
+   omap_plane_atomic_destroy_state(plane, plane->state);
+
+   omap_state = kzalloc(sizeof(*omap_state), GFP_KERNEL);
+   if (!omap_state)
return;
 
+   omap_state->base.plane = plane;
+   plane->state = _state->base;
+   plane->state->plane = plane;
+   plane->state->rotation = DRM_MODE_ROTATE_0;
/*
 * Set the zpos default depending on whether we are a primary or overlay
 * plane.
@@ -218,6 +239,25 @@ static void omap_plane_reset(struct drm_plane *plane)
   ? 0 : omap_plane->overlay->overlay_id;
 }
 
+static struct drm_plane_state *
+omap_plane_atomic_duplicate_state(struct drm_plane *plane)
+{
+   struct omap_plane_state *state;
+   struct omap_plane_state *copy;
+
+   if (WARN_ON(!plane->state))
+   return NULL;
+
+   state = to_omap_plane_state(plane->state);
+   copy = kmemdup(state, sizeof(*state), GFP_KERNEL);
+   if (!copy)
+   return NULL;
+
+   __drm_atomic_helper_plane_duplicate_state(plane, >base);
+
+   return >base;
+}
+
 static int omap_plane_atomic_set_property(struct drm_plane *plane,
  struct drm_plane_state *state,
  struct drm_property *property,
@@ -253,8 +293,8 @@ static const struct drm_plane_funcs omap_plane_funcs = {
.disable_plane = drm_atomic_helper_disable_plane,
.reset = omap_plane_reset,
.destroy = omap_plane_destroy,
-   .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
-   .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
+   .atomic_duplicate_state = omap_plane_atomic_duplicate_state,
+   .atomic_destroy_state = omap_plane_atomic_destroy_state,
.atomic_set_property = omap_plane_atomic_set_property,
.atomic_get_property = omap_plane_atomic_get_property,
 };
-- 
2.9.0

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


[Patch v4 8/8] drm/omap: Add a 'right overlay' to plane state

2018-10-12 Thread Benoit Parrot
If the drm_plane has a source width that's greater than the max width
supported by a single hw overlay, then we assign a 'r_overlay' to it in
omap_plane_atomic_check().

Both overlays should have the capabilities required to handle the source
framebuffer. The only parameters that vary between the left and right
hwoverlays are the src_w, crtc_w, src_x and crtc_x as we just even chop
the fb into left and right halves.

We also take care of not creating odd width size when dealing with YUV
formats.

Since both halves need to be 'appear' side by side the zpos is
recalculated when dealing with dual overlay cases so that the other
planes zpos is consistent.

Depending on user space usage it is possible that on occasion the number
of requested planes exceeds the numbers of overlays required to display
them. In that case a failure would be returned for the plane that cannot
be handled at that time. It is up to user space to make sure the H/W
resource are not over-subscribed.

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/omapdrm/omap_drv.c |  91 ++-
 drivers/gpu/drm/omapdrm/omap_fb.c  |  33 -
 drivers/gpu/drm/omapdrm/omap_fb.h  |   4 +-
 drivers/gpu/drm/omapdrm/omap_overlay.c |  31 +++-
 drivers/gpu/drm/omapdrm/omap_overlay.h |   3 +-
 drivers/gpu/drm/omapdrm/omap_plane.c   | 128 +++--
 drivers/gpu/drm/omapdrm/omap_plane.h   |   1 +
 7 files changed, 278 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 94658ec79c76..307cd905fd02 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -118,6 +118,95 @@ static void omap_atomic_commit_tail(struct 
drm_atomic_state *old_state)
priv->dispc_ops->runtime_put(priv->dispc);
 }
 
+static int drm_atomic_state_normalized_zpos_cmp(const void *a, const void *b)
+{
+   const struct drm_plane_state *sa = *(struct drm_plane_state **)a;
+   const struct drm_plane_state *sb = *(struct drm_plane_state **)b;
+
+   if (sa->normalized_zpos != sb->normalized_zpos)
+   return sa->normalized_zpos - sb->normalized_zpos;
+   else
+   return sa->plane->base.id - sb->plane->base.id;
+}
+
+static int omap_atomic_update_normalize_zpos(struct drm_device *dev,
+struct drm_atomic_state *state)
+{
+   struct drm_crtc *crtc;
+   struct drm_crtc_state *old_state, *new_state;
+   struct drm_plane *plane;
+   int c, i, n, inc;
+   int total_planes = dev->mode_config.num_total_plane;
+   struct drm_plane_state **states;
+   int ret = 0;
+
+   states = kmalloc_array(total_planes, sizeof(*states), GFP_KERNEL);
+   if (!states)
+   return -ENOMEM;
+
+   for_each_oldnew_crtc_in_state(state, crtc, old_state, new_state, c) {
+   if (old_state->plane_mask == new_state->plane_mask &&
+   !new_state->zpos_changed)
+   continue;
+
+   /* Reset plane increment and index value for every crtc */
+   n = 0;
+
+   /*
+* Normalization process might create new states for planes
+* which normalized_zpos has to be recalculated.
+*/
+   drm_for_each_plane_mask(plane, dev, new_state->plane_mask) {
+   struct drm_plane_state *plane_state =
+   drm_atomic_get_plane_state(new_state->state,
+  plane);
+   if (IS_ERR(plane_state)) {
+   ret = PTR_ERR(plane_state);
+   goto done;
+   }
+   states[n++] = plane_state;
+   }
+
+   sort(states, n, sizeof(*states),
+drm_atomic_state_normalized_zpos_cmp, NULL);
+
+   for (i = 0, inc = 0; i < n; i++) {
+   plane = states[i]->plane;
+
+   states[i]->normalized_zpos = i + inc;
+   DRM_DEBUG_ATOMIC("[PLANE:%d:%s] updated normalized zpos 
value %d\n",
+plane->base.id, plane->name,
+states[i]->normalized_zpos);
+
+   if (is_omap_plane_dual_overlay(states[i]))
+   inc++;
+   }
+   new_state->zpos_changed = true;
+   }
+
+done:
+   kfree(states);
+   return ret;
+}
+
+static int omap_atomic_check(struct drm_device *dev,
+struct drm_atomic_state *state)
+{
+   int ret;
+
+   ret = drm_atomic_helper_check(dev, state);
+   if (ret)
+   return ret;
+
+   if (dev->mode_config.normalize_zpos) {

[Patch v4 2/8] drm/omap: Add ovl checking funcs to dispc_ops

2018-10-12 Thread Benoit Parrot
In order to be able to dynamically assign overlays to planes we need to
be able to asses the overlay capabilities.

Add a helper function to be able to retrieve the supported capabilities
of an overlay.

And export the function to check if a fourcc is supported on a given
overlay.

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 8 
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 4 
 2 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 70c3e3353947..ea8b57003620 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -2499,6 +2499,12 @@ static int dispc_ovl_calc_scaling_44xx(struct 
dispc_device *dispc,
return 0;
 }
 
+static enum omap_overlay_caps dispc_ovl_get_caps(struct dispc_device *dispc,
+enum omap_plane_id plane)
+{
+   return dispc->feat->overlay_caps[plane];
+}
+
 #define DIV_FRAC(dividend, divisor) \
((dividend) * 100 / (divisor) - ((dividend) / (divisor) * 100))
 
@@ -4757,6 +4763,8 @@ static const struct dispc_ops dispc_ops = {
.ovl_enable = dispc_ovl_enable,
.ovl_setup = dispc_ovl_setup,
.ovl_get_color_modes = dispc_ovl_get_color_modes,
+   .ovl_color_mode_supported = dispc_ovl_color_mode_supported,
+   .ovl_get_caps = dispc_ovl_get_caps,
.ovl_get_max_size = dispc_ovl_get_max_size,
 
.wb_get_framedone_irq = dispc_wb_get_framedone_irq,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 45334d5c618e..b5640e8479dc 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -632,6 +632,10 @@ struct dispc_ops {
 
const u32 *(*ovl_get_color_modes)(struct dispc_device *dispc,
  enum omap_plane_id plane);
+   bool (*ovl_color_mode_supported)(struct dispc_device *dispc,
+enum omap_plane_id plane, u32 fourcc);
+   enum omap_overlay_caps (*ovl_get_caps)(struct dispc_device *dispc,
+  enum omap_plane_id plane);
void (*ovl_get_max_size)(struct dispc_device *dispc,
 u16 *width, u16 *height);
 
-- 
2.9.0

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


[Patch v4 6/8] drm/omap: dynamically assign hw overlays to planes

2018-10-12 Thread Benoit Parrot
(re)assign the hw overlays to planes based on required caps, and to
handle situations where we could not modify an in-use plane.

This means all planes advertise the superset of formats and properties.
Userspace must (as always) use atomic TEST_ONLY step for atomic updates,
as not all planes may be available for use on every frame.

The mapping of hwoverlays to plane is stored in omap_global_state, so
that state updates are atomically committed in the same way that
plane/etc state updates are managed.  This is needed because the
omap_plane_state keeps a pointer to the hwoverlay, and we don't want
global state to become out of sync with the plane state if an atomic
update fails, we hit deadlock/ backoff scenario, etc.  The use of
global_state_lock keeps multiple parallel updates which both re-assign
hwoverlays properly serialized.

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/omapdrm/omap_drv.h |   3 +
 drivers/gpu/drm/omapdrm/omap_overlay.c | 143 ++
 drivers/gpu/drm/omapdrm/omap_overlay.h |   9 ++
 drivers/gpu/drm/omapdrm/omap_plane.c   | 153 ++---
 4 files changed, 276 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h 
b/drivers/gpu/drm/omapdrm/omap_drv.h
index f374dc100447..00326f2a2c2c 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -64,6 +64,9 @@ struct omap_global_state {
struct drm_private_state base;
 
struct drm_atomic_state *state;
+
+   /* global atomic state of assignment between overlays and planes */
+   struct drm_plane *hwoverlay_to_plane[8];
 };
 
 struct omap_drm_private {
diff --git a/drivers/gpu/drm/omapdrm/omap_overlay.c 
b/drivers/gpu/drm/omapdrm/omap_overlay.c
index 7a09b0aa823a..3a58582cd56f 100644
--- a/drivers/gpu/drm/omapdrm/omap_overlay.c
+++ b/drivers/gpu/drm/omapdrm/omap_overlay.c
@@ -21,6 +21,149 @@ static const char * const overlay_id_to_name[] = {
[OMAP_DSS_VIDEO3] = "vid3",
 };
 
+static struct omap_hw_overlay *
+omap_plane_find_free_overlay(struct drm_device *dev,
+struct drm_plane *hwoverlay_to_plane[],
+u32 caps, u32 fourcc, u32 crtc_mask)
+{
+   struct omap_drm_private *priv = dev->dev_private;
+   const struct dispc_ops *ops = priv->dispc_ops;
+   int i;
+
+   DBG("caps: %x fourcc: %x crtc: %x", caps, fourcc, crtc_mask);
+
+   for (i = 0; i < priv->num_ovls; i++) {
+   struct omap_hw_overlay *cur = priv->overlays[i];
+
+   DBG("%d: id: %d cur->caps: %x cur->crtc: %x",
+   cur->idx, cur->overlay_id, cur->caps, cur->possible_crtcs);
+
+   /* skip if already in-use */
+   if (hwoverlay_to_plane[cur->idx])
+   continue;
+
+   /* check if allowed on crtc */
+   if (!(cur->possible_crtcs & crtc_mask))
+   continue;
+
+   /* skip if doesn't support some required caps: */
+   if (caps & ~cur->caps)
+   continue;
+
+   /* check supported format */
+   if (!ops->ovl_color_mode_supported(priv->dispc,
+  cur->overlay_id,
+  fourcc))
+   continue;
+
+   return cur;
+   }
+
+   DBG("no match");
+   return NULL;
+}
+
+int omap_overlay_assign(struct drm_atomic_state *s, struct drm_plane *plane,
+   u32 caps, u32 fourcc, u32 crtc_mask,
+   struct omap_hw_overlay **overlay)
+{
+   struct omap_drm_private *priv = s->dev->dev_private;
+   struct omap_global_state *new_global_state, *old_global_state;
+   struct drm_plane **overlay_map;
+   struct omap_hw_overlay *ovl;
+
+   new_global_state = omap_get_global_state(s);
+   if (IS_ERR(new_global_state))
+   return PTR_ERR(new_global_state);
+
+   /*
+* grab old_state after omap_get_global_state(),
+* since now we hold lock:
+*/
+   old_global_state = omap_get_existing_global_state(priv);
+   DBG("new_global_state: %p old_global_state: %p",
+   new_global_state, old_global_state);
+
+   overlay_map = new_global_state->hwoverlay_to_plane;
+
+   if (!*overlay) {
+   ovl = omap_plane_find_free_overlay(s->dev, overlay_map,
+  caps, fourcc, crtc_mask);
+   if (!ovl)
+   return -ENOMEM;
+
+   ovl->possible_crtcs = crtc_mask;
+   overlay_map[ovl->idx] = plane;
+   *overlay = ovl;
+
+   DBG("%s: assign to plane %s caps %x on crtc %x",
+   

[RFC 1/3] drm/omap: Add ability to check if requested plane modes can be supported

2018-06-29 Thread Benoit Parrot
We currently assumed that an overlay has the same width and height as
the overlay manager. This assumption is incorrect. On some variant the
overlay manager is twice the width that the overlay can handle. We need
to add the appropriate data per variant as well as export a helper
function to retrieve the data so check can be made dynamically. We
currently add such a check in the dispc_ovl_setup() which will return an
error along with a WARN in case the required width exceed the overlay's
ability.

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 29 +
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  2 ++
 2 files changed, 31 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index cfdcc3681494..1b7a6ef7897f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -103,6 +103,8 @@ struct dispc_features {
u8 mgr_height_start;
u16 mgr_width_max;
u16 mgr_height_max;
+   u16 ovl_width_max;
+   u16 ovl_height_max;
unsigned long max_lcd_pclk;
unsigned long max_tv_pclk;
unsigned int max_downscale;
@@ -2605,6 +2607,13 @@ static int dispc_ovl_calc_scaling(struct dispc_device 
*dispc,
return 0;
 }
 
+static void dispc_ovl_get_max_size(struct dispc_device *dispc,
+  u16 *width, u16 *height)
+{
+   *width = dispc->feat->ovl_width_max;
+   *height = dispc->feat->ovl_height_max;
+}
+
 static int dispc_ovl_setup_common(struct dispc_device *dispc,
  enum omap_plane_id plane,
  enum omap_overlay_caps caps,
@@ -2648,6 +2657,11 @@ static int dispc_ovl_setup_common(struct dispc_device 
*dispc,
out_width = out_width == 0 ? width : out_width;
out_height = out_height == 0 ? height : out_height;
 
+   if (WARN(out_width > dispc->feat->ovl_width_max,
+"Requested OVL width (%d) is larger than can be supported 
(%d).\n",
+out_width, dispc->feat->ovl_width_max))
+   return -EINVAL;
+
if (plane != OMAP_DSS_WB) {
if (ilace && height == out_height)
fieldmode = true;
@@ -4262,6 +4276,8 @@ static const struct dispc_features omap24xx_dispc_feats = 
{
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   6650,
.max_downscale  =   2,
/*
@@ -4299,6 +4315,8 @@ static const struct dispc_features 
omap34xx_rev1_0_dispc_feats = {
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17300,
.max_tv_pclk=   5900,
.max_downscale  =   4,
@@ -4333,6 +4351,8 @@ static const struct dispc_features 
omap34xx_rev3_0_dispc_feats = {
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17300,
.max_tv_pclk=   5900,
.max_downscale  =   4,
@@ -4367,6 +4387,8 @@ static const struct dispc_features omap36xx_dispc_feats = 
{
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17300,
.max_tv_pclk=   5900,
.max_downscale  =   4,
@@ -4401,6 +4423,8 @@ static const struct dispc_features am43xx_dispc_feats = {
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17300,
.max_tv_pclk=   5900,
.max_downscale  =   4,
@@ -4435,6 +4459,8 @@ static const struct dispc_features omap44xx_dispc_feats = 
{
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17000,
.max_tv_pclk=   185625000,

[RFC 0/3] drm/omap: Add virtual wide planes support

2018-06-29 Thread Benoit Parrot
This patch series adds virtual wide plane support to omapdrm driver to
allow the use of display wider than 2048 pixels. This is achieve by
adding replacing the static omapdrm plane to hardware overlay static
mapping with a dynamic allocation method.

This replaces an original early series which the introduction of new DT
sub nodes. Since this solution is pretty different for the first few
iterations I decide to send as an RFC.

This implementation is inspired from the work done in msm/disp/mdp5
driver.

There is one issue that I did face while using the ww mutex for which I
would like reviewer to pay attention and comment on. You can find my
questions just before the omap_overlay_disable_unassigned() function in
drivers/gpu/drm/omapdrm/omap_overlay.c.


Benoit Parrot (3):
  drm/omap: Add ability to check if requested plane modes can be
supported
  drm/omap: Add ovl checking funcs to dispc_ops
  drm/omap: Add wide display support using multiple overlays

 drivers/gpu/drm/omapdrm/Makefile   |   1 +
 drivers/gpu/drm/omapdrm/dss/dispc.c|  37 
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |   6 +
 drivers/gpu/drm/omapdrm/omap_drv.c | 119 ++-
 drivers/gpu/drm/omapdrm/omap_drv.h |  15 +-
 drivers/gpu/drm/omapdrm/omap_fb.c  |  33 ++-
 drivers/gpu/drm/omapdrm/omap_fb.h  |   4 +-
 drivers/gpu/drm/omapdrm/omap_overlay.c | 366 +
 drivers/gpu/drm/omapdrm/omap_overlay.h |  80 +++
 drivers/gpu/drm/omapdrm/omap_plane.c   | 322 -
 drivers/gpu/drm/omapdrm/omap_plane.h   |  20 ++
 11 files changed, 935 insertions(+), 68 deletions(-)
 create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.c
 create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.h

-- 
2.9.0

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


[RFC 3/3] drm/omap: Add wide display support using multiple overlays

2018-06-29 Thread Benoit Parrot
In the case where we need to support wide-display using more than one
overlay to achieve the needed display resolution, we need to be able to
dynamically assign overlays to planes instead of having the overlays
being statically mapped to planes.

This also means that on occasion where the number of requested planes
exceeds the numbers of overlays required to display them then a failure
would be returned for the plane that cannot be handled at that time. It
is up to user space to make sure the H/W resource are not
over-subscribed.

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/omapdrm/Makefile   |   1 +
 drivers/gpu/drm/omapdrm/omap_drv.c | 119 ++-
 drivers/gpu/drm/omapdrm/omap_drv.h |  15 +-
 drivers/gpu/drm/omapdrm/omap_fb.c  |  33 ++-
 drivers/gpu/drm/omapdrm/omap_fb.h  |   4 +-
 drivers/gpu/drm/omapdrm/omap_overlay.c | 366 +
 drivers/gpu/drm/omapdrm/omap_overlay.h |  80 +++
 drivers/gpu/drm/omapdrm/omap_plane.c   | 322 -
 drivers/gpu/drm/omapdrm/omap_plane.h   |  20 ++
 9 files changed, 892 insertions(+), 68 deletions(-)
 create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.c
 create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.h

diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
index f115253115c5..800dfd035360 100644
--- a/drivers/gpu/drm/omapdrm/Makefile
+++ b/drivers/gpu/drm/omapdrm/Makefile
@@ -12,6 +12,7 @@ omapdrm-y := omap_drv.o \
omap_debugfs.o \
omap_crtc.o \
omap_plane.o \
+   omap_overlay.o \
omap_encoder.o \
omap_connector.o \
omap_fb.o \
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index ef3b0e3571ec..f0a5c3dab471 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -16,11 +16,7 @@
  */
 
 #include 
-
-#include 
-#include 
-#include 
-#include 
+#include 
 
 #include "omap_dmm_tiler.h"
 #include "omap_drv.h"
@@ -113,9 +109,100 @@ static void omap_atomic_commit_tail(struct 
drm_atomic_state *old_state)
 
drm_atomic_helper_cleanup_planes(dev, old_state);
 
+   omap_overlay_disable_unassigned(old_state);
+
priv->dispc_ops->runtime_put(priv->dispc);
 }
 
+static int drm_atomic_state_normalized_zpos_cmp(const void *a, const void *b)
+{
+   const struct drm_plane_state *sa = *(struct drm_plane_state **)a;
+   const struct drm_plane_state *sb = *(struct drm_plane_state **)b;
+
+   if (sa->normalized_zpos != sb->normalized_zpos)
+   return sa->normalized_zpos - sb->normalized_zpos;
+   else
+   return sa->plane->base.id - sb->plane->base.id;
+}
+
+static int omap_atomic_update_normalize_zpos(struct drm_device *dev,
+struct drm_atomic_state *state)
+{
+   struct drm_crtc *crtc;
+   struct drm_crtc_state *old_state, *new_state;
+   struct drm_plane *plane;
+   int i, n, inc;
+   int total_planes = dev->mode_config.num_total_plane;
+   struct drm_plane_state **states;
+   int ret = 0;
+
+   states = kmalloc_array(total_planes, sizeof(*states), GFP_KERNEL);
+   if (!states)
+   return -ENOMEM;
+
+   for_each_oldnew_crtc_in_state(state, crtc, old_state, new_state, i) {
+   if (old_state->plane_mask == new_state->plane_mask &&
+   !new_state->zpos_changed)
+   continue;
+
+   /* Reset plane increment and index value for every crtc */
+   n = 0;
+
+   /*
+* Normalization process might create new states for planes
+* which normalized_zpos has to be recalculated.
+*/
+   drm_for_each_plane_mask(plane, dev, new_state->plane_mask) {
+   struct drm_plane_state *plane_state =
+   drm_atomic_get_plane_state(new_state->state,
+  plane);
+   if (IS_ERR(plane_state)) {
+   ret = PTR_ERR(plane_state);
+   goto done;
+   }
+   states[n++] = plane_state;
+   }
+
+   sort(states, n, sizeof(*states),
+drm_atomic_state_normalized_zpos_cmp, NULL);
+
+   for (i = 0, inc = 0; i < n; i++) {
+   plane = states[i]->plane;
+
+   states[i]->normalized_zpos = i + inc;
+   DRM_DEBUG_ATOMIC("[PLANE:%d:%s] updated normalized zpos 
value %d\n",
+plane->base.id, plane->name,
+states[i]->normalized_zpos);
+
+   if (is_omap_plane_dual_overlay(s

[RFC 2/3] drm/omap: Add ovl checking funcs to dispc_ops

2018-06-29 Thread Benoit Parrot
In order to be able to dynamically assign overlays to planes we need to
be able to asses the overlay capabilities.

Add a helper function to be able to retrieve the supported capabilities
of an overlay.

And export the function to check if a fourcc is supported on a given
overlay.

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 8 
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 4 
 2 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 1b7a6ef7897f..80ac1e68a036 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -2508,6 +2508,12 @@ static int dispc_ovl_calc_scaling_44xx(struct 
dispc_device *dispc,
return 0;
 }
 
+static enum omap_overlay_caps dispc_ovl_get_caps(struct dispc_device *dispc,
+enum omap_plane_id plane)
+{
+   return dispc->feat->overlay_caps[plane];
+}
+
 #define DIV_FRAC(dividend, divisor) \
((dividend) * 100 / (divisor) - ((dividend) / (divisor) * 100))
 
@@ -4777,6 +4783,8 @@ static const struct dispc_ops dispc_ops = {
.ovl_enable = dispc_ovl_enable,
.ovl_setup = dispc_ovl_setup,
.ovl_get_color_modes = dispc_ovl_get_color_modes,
+   .ovl_color_mode_supported = dispc_ovl_color_mode_supported,
+   .ovl_get_caps = dispc_ovl_get_caps,
.ovl_get_max_size = dispc_ovl_get_max_size,
 
.wb_get_framedone_irq = dispc_wb_get_framedone_irq,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 3f264759eecb..01fbd674a021 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -743,6 +743,10 @@ struct dispc_ops {
 
const u32 *(*ovl_get_color_modes)(struct dispc_device *dispc,
  enum omap_plane_id plane);
+   bool (*ovl_color_mode_supported)(struct dispc_device *dispc,
+enum omap_plane_id plane, u32 fourcc);
+   enum omap_overlay_caps (*ovl_get_caps)(struct dispc_device *dispc,
+  enum omap_plane_id plane);
void (*ovl_get_max_size)(struct dispc_device *dispc,
 u16 *width, u16 *height);
 
-- 
2.9.0

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


Re: omapdrm regression in v4.17-rc series

2018-05-24 Thread Benoit Parrot
Reviewed-by: Benoit Parrot <bpar...@ti.com>

Tomi Valkeinen <tomi.valkei...@ti.com> wrote on Thu [2018-May-24 10:58:25 
+0300]:
> 
> On 24/05/18 01:03, Tony Lindgren wrote:
> > Hi all,
> > 
> > I bisected the n900 LCD issue to commit 24aac6011f70 ("drm: omapdrm:
> > sdi: Allocate the sdi private data structure dynamically"). Reverting
> > this patch makes LCD work for me again on n900.
> > 
> > Any ideas?
> 
> This should help to get the SDI enabled.
> 
>  Tomi
> 
> From 4e96e6c2dedf366e081331c3825ff6fa8aabd85c Mon Sep 17 00:00:00 2001
> From: Tomi Valkeinen <tomi.valkei...@ti.com>
> Date: Thu, 24 May 2018 10:53:24 +0300
> Subject: [PATCH] drm/omap: fix NULL deref crash with SDI displays
> 
> Fix a NULL deref bug introduced in commit 24aac6011f70 ("drm: omapdrm:
> sdi: Allocate the sdi private data structure dynamically").
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkei...@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/sdi.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c 
> b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index 68a40ae26f5b..1e2c931f6acf 100644
> --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> @@ -82,7 +82,7 @@ static int sdi_calc_clock_div(struct sdi_device *sdi, 
> unsigned long pclk,
> struct dispc_clock_info *dispc_cinfo)
>  {
>   int i;
> - struct sdi_clk_calc_ctx ctx = { .sdi = sdi };
> + struct sdi_clk_calc_ctx ctx;
>  
>   /*
>* DSS fclk gives us very few possibilities, so finding a good pixel
> @@ -95,6 +95,9 @@ static int sdi_calc_clock_div(struct sdi_device *sdi, 
> unsigned long pclk,
>   bool ok;
>  
>   memset(, 0, sizeof(ctx));
> +
> + ctx.sdi = sdi;
> +
>   if (pclk > 1000 * i * i * i)
>   ctx.pck_min = max(pclk - 1000 * i * i * i, 0lu);
>   else
> 
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 0/4] drm/omap: minor fixes

2018-05-03 Thread Benoit Parrot
For the series,

Reviewed-by: Benoit Parrot <bpar...@ti.com>

Tomi Valkeinen <tomi.valkei...@ti.com> wrote on Wed [2018-May-02 12:11:55 
+0300]:
> Hi,
> 
> This series has some minor fixes found by a static analysis tool, and one for
> missing linefeeds.  As far as I know, we have never hit any of those errors.
> 
>  Tomi
> 
> Tomi Valkeinen (4):
>   drm/omap: check return value from soc_device_match
>   drm/omap: handle error if scale coefs are not found
>   drm/omap: add missing linefeeds to prints
>   drm/omap: handle alloc failures in omap_connector
> 
>  drivers/gpu/drm/omapdrm/dss/dispc.c  | 20 +---
>  drivers/gpu/drm/omapdrm/dss/hdmi4_core.c |  7 ++-
>  drivers/gpu/drm/omapdrm/omap_connector.c | 10 ++
>  3 files changed, 29 insertions(+), 8 deletions(-)
> 
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Patch v2 2/6] dt-bindings: display/ti: Move common dispc bindings to omap-dss.txt

2018-04-27 Thread Benoit Parrot
Laurent Pinchart <laurent.pinch...@ideasonboard.com> wrote on Wed [2018-Apr-04 
17:29:59 +0300]:
> Hi Benoit,
> 
> Thank you for the patch.
> 
> On Monday, 26 March 2018 19:21:24 EEST Benoit Parrot wrote:
> > Add common DISPC bindings into the top level bindings file.
> > Move common bindings here instead of having multiple copies of
> > the same information in all of the variant specific files.
> > 
> > Signed-off-by: Benoit Parrot <bpar...@ti.com>
> > Reviewed-by: Rob Herring <r...@kernel.org>
> > ---
> >  Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt  | 5 -
> >  Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt  | 7 +++
> >  Documentation/devicetree/bindings/display/ti/ti,omap2-dss.txt | 4 
> >  Documentation/devicetree/bindings/display/ti/ti,omap3-dss.txt | 4 
> >  Documentation/devicetree/bindings/display/ti/ti,omap4-dss.txt | 4 
> >  Documentation/devicetree/bindings/display/ti/ti,omap5-dss.txt | 4 
> >  6 files changed, 7 insertions(+), 21 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt
> > b/Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt index
> > 91279f1060fe..c30f9ec189ed 100644
> > --- a/Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt
> > +++ b/Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt
> > @@ -47,11 +47,6 @@ Required properties:
> >  - clocks: handle to fclk
> >  - clock-names: "fck"
> > 
> > -Optional properties:
> > -- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth
> > limit - in bytes per second
> > -
> > -
> >  HDMI
> >  
> > 
> > diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
> > b/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt index
> > e1ef29569338..249e588d7865 100644
> > --- a/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
> > +++ b/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
> > @@ -21,6 +21,13 @@ a RGB pixel stream to encoders.
> >  The encoder modules encode the received RGB pixel stream to a video output
> > like HDMI, MIPI DPI, etc.
> > 
> > +DISPC
> > +-
> > +
> > +Optional properties:
> > +- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth
> > limit
> > +   in bytes per second
> > +
> 
> I like the idea, but I think you need to expand the description a bit. 
> ti,omap-dss.txt should explain how each module should be represented by a 
> child DT node in the DSS DT node, and this section should briefly explain 
> what 
> the DISPC is (you can simply move the 4th paragraph of the file here) and 
> that 
> it describes common properties.

Yes, I'll do that in the next revision.
  
> You could also move the description of other 
> DISPC properties here.

I had done that originally but Tomi pointed out that most of the other
properties are not common with all of the platform variants, some would
have multiple clocks or registers block or no hwmod components. I thought
it would more confusing to have some of those variant specific "required"
properties be shown here as optional.

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


Re: [Patch v2 1/6] drm/omap: Add ability to filter out modes which can't be supported

2018-04-04 Thread Benoit Parrot
Tomi Valkeinen <tomi.valkei...@ti.com> wrote on Wed [2018-Apr-04 14:12:13 
+0300]:
> On 26/03/18 19:21, Benoit Parrot wrote:
> > Currently available display mode from a connector are filtered out
> > based only on pixel clock capability. However we also need to filter
> > out wider mode if we cannot handle them based on available pipeline
> > capabilities.
> > 
> > Signed-off-by: Benoit Parrot <bpar...@ti.com>
> > ---
> >  drivers/gpu/drm/omapdrm/dss/dispc.c  | 27 +++
> >  drivers/gpu/drm/omapdrm/dss/omapdss.h|  1 +
> >  drivers/gpu/drm/omapdrm/omap_connector.c | 10 ++
> >  3 files changed, 38 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
> > b/drivers/gpu/drm/omapdrm/dss/dispc.c
> > index 624dee22f46b..35541d4441df 100644
> > --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> > +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> > @@ -100,6 +100,8 @@ struct dispc_features {
> > u8 mgr_height_start;
> > u16 mgr_width_max;
> > u16 mgr_height_max;
> > +   u16 ovl_width_max;
> > +   u16 ovl_height_max;
> > unsigned long max_lcd_pclk;
> > unsigned long max_tv_pclk;
> > unsigned int max_downscale;
> > @@ -2465,6 +2467,12 @@ static int dispc_ovl_calc_scaling(unsigned long 
> > pclk, unsigned long lclk,
> > return 0;
> >  }
> >  
> > +static void dispc_ovl_get_max_size(u16 *width, u16 *height)
> > +{
> > +   *width = dispc.feat->ovl_width_max;
> > +   *height = dispc.feat->ovl_height_max;
> > +}
> > +
> >  static int dispc_ovl_setup_common(enum omap_plane_id plane,
> > enum omap_overlay_caps caps, u32 paddr, u32 p_uv_addr,
> > u16 screen_width, int pos_x, int pos_y, u16 width, u16 height,
> > @@ -2500,6 +2508,10 @@ static int dispc_ovl_setup_common(enum omap_plane_id 
> > plane,
> > out_width = out_width == 0 ? width : out_width;
> > out_height = out_height == 0 ? height : out_height;
> >  
> > +   WARN(out_width > dispc.feat->ovl_width_max,
> > +"Requested OVL width (%d) is larger than can be supported (%d).\n",
> > +out_width, dispc.feat->ovl_width_max);
> 
> Why don't you return an error here? I don't see a need for WARN here.

So here you mean replace the WARN with something like this:

if (out_width > dispc.feat->ovl_width_max) {
DSSERR("Requested OVL width (%d) is larger than can be 
supported (%d).\n",
   out_width, dispc.feat->ovl_width_max);
return -EINVAL;
}

> 
> >  void dispc_set_ops(const struct dispc_ops *o);
> > diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c 
> > b/drivers/gpu/drm/omapdrm/omap_connector.c
> > index a0d7b1d905e8..d5e059abb555 100644
> > --- a/drivers/gpu/drm/omapdrm/omap_connector.c
> > +++ b/drivers/gpu/drm/omapdrm/omap_connector.c
> > @@ -197,6 +197,16 @@ static int omap_connector_mode_valid(struct 
> > drm_connector *connector,
> > r = 0;
> > }
> >  
> > +   /* Check if the advertised width exceed what the pipeline can do */
> > +   if (!r) {
> > +   struct omap_drm_private *priv = dev->dev_private;
> > +   u16 width, height;
> > +
> > +   priv->dispc_ops->ovl_get_max_size(, );
> > +   if (mode->hdisplay > width)
> > +   r = -EINVAL;
> 
> You should check the height also.

Yeah, I'll fix that.

Benoit

> 
>  Tomi
> 
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Patch v2 5/6] drm/omap: Add virtual plane support to omap_plane

2018-03-26 Thread Benoit Parrot
Add virtual wide plane support by adding an secondary
plane_id so that an "omap_plane" can be composed of up to
two physical planes.

When at least one 'plane' child node is present in DT then
omap_plane_init will only use the plane described in DT.
Some of these nodes may be a virtual wide plane if they are defined
as two physical planes.
Planes can also be associated with various crtcs independently.
Therefore we can restrict the use of virtual plane to specific
CRTC/video port if need be, if crtc_mask is not specified then
the plane will be available to all available crtcs.
Physical planes which are not described will essentially be hidden
from the driver.

If no 'plane' child nodes exist then the normal plane
allocation will take place.

Signed-off-by: Benoit Parrot <bpar...@ti.com>
---
 drivers/gpu/drm/omapdrm/omap_drv.c   | 127 +++--
 drivers/gpu/drm/omapdrm/omap_fb.c|  66 ++-
 drivers/gpu/drm/omapdrm/omap_fb.h|   4 +-
 drivers/gpu/drm/omapdrm/omap_plane.c | 151 ++-
 drivers/gpu/drm/omapdrm/omap_plane.h |   4 +-
 5 files changed, 283 insertions(+), 69 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 37ee20c773c7..4c43ef239136 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -16,6 +16,7 @@
  */
 
 #include 
+#include 
 
 #include 
 #include 
@@ -116,6 +117,112 @@ static void omap_atomic_commit_tail(struct 
drm_atomic_state *old_state)
priv->dispc_ops->runtime_put();
 }
 
+static int omap_atomic_state_zpos_cmp(const void *a, const void *b)
+{
+   const struct drm_plane_state *sa = *(struct drm_plane_state **)a;
+   const struct drm_plane_state *sb = *(struct drm_plane_state **)b;
+
+   if (sa->zpos != sb->zpos)
+   return sa->zpos - sb->zpos;
+   else
+   return sa->plane->base.id - sb->plane->base.id;
+}
+
+static int omap_atomic_crtc_normalize_zpos(struct drm_crtc *crtc,
+  struct drm_crtc_state *crtc_state)
+{
+   struct drm_atomic_state *state = crtc_state->state;
+   struct drm_device *dev = crtc->dev;
+   int total_planes = dev->mode_config.num_total_plane;
+   struct drm_plane_state **states;
+   struct drm_plane *plane;
+   int i, inc, n = 0;
+   int ret = 0;
+
+   DRM_DEBUG_ATOMIC("[CRTC:%d:%s] calculating normalized zpos values\n",
+crtc->base.id, crtc->name);
+
+   states = kmalloc_array(total_planes, sizeof(*states), GFP_KERNEL);
+   if (!states)
+   return -ENOMEM;
+
+   /*
+* Normalization process might create new states for planes which
+* normalized_zpos has to be recalculated.
+*/
+   drm_for_each_plane_mask(plane, dev, crtc_state->plane_mask) {
+   struct drm_plane_state *plane_state =
+   drm_atomic_get_plane_state(state, plane);
+   if (IS_ERR(plane_state)) {
+   ret = PTR_ERR(plane_state);
+   goto done;
+   }
+   states[n++] = plane_state;
+   DRM_DEBUG_ATOMIC("[PLANE:%d:%s] processing zpos value %d\n",
+plane->base.id, plane->name,
+plane_state->zpos);
+   }
+
+   sort(states, n, sizeof(*states), omap_atomic_state_zpos_cmp, NULL);
+
+   for (inc = 0, i = 0; i < n; i++) {
+   plane = states[i]->plane;
+
+   states[i]->normalized_zpos = i + inc;
+   DRM_DEBUG_ATOMIC("[PLANE:%d:%s] normalized zpos value %d\n",
+plane->base.id, plane->name, i + inc);
+   /*
+* If the current plane is virtual it uses 2 hw planes
+* therefore the very next zpos is used by the secondary/aux
+* plane so we need to skip one zpos from this point on.
+*/
+   if (is_omap_plane_virtual(plane))
+   inc++;
+   }
+   crtc_state->zpos_changed = true;
+
+done:
+   kfree(states);
+   return ret;
+}
+
+static int omap_atomic_normalize_zpos(struct drm_device *dev,
+ struct drm_atomic_state *state)
+{
+   struct drm_crtc *crtc;
+   struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+   int i, ret = 0;
+
+   for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, 
new_crtc_state, i) {
+   if (old_crtc_state->plane_mask != new_crtc_state->plane_mask ||
+   new_crtc_state->zpos_changed) {
+   ret = omap_atomic_crtc_normalize_zpos(crtc,
+ new_crtc_state);
+   if 

[Patch v2 3/6] dt-bindings: display/ti: Add plane binding to dispc node

2018-03-26 Thread Benoit Parrot
Currently all available display pipelines (i.e. plane) and output port
resources are exposed to user-space. In some cases it is needed to be
able to restrict which resources are actually visible from user-space.
Also in cases where a display wider than 2048 pixels is to be supported
more than one video pipeline is needed. In this case the 2nd hardware
pipeline needed is not visible to user space applications.

These video pipeline definitions must be statically defined so that
the number of visible pipelines does not change from the user-space
perspective.

In order to allow this we are adding an optional 'plane' sub-node to
the generic DISPC node.

Signed-off-by: Benoit Parrot <bpar...@ti.com>
---
 .../devicetree/bindings/display/ti/ti,omap-dss.txt | 65 ++
 1 file changed, 65 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
index 249e588d7865..2dd411cb5a83 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
@@ -28,6 +28,36 @@ Optional properties:
 - max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
in bytes per second
 
+Optional Subnode:
+- plane: Child node(s) which defines which video planes are available to
+   the system. If at least one plane child node is defined then
+   only planes defined by these nodes will be available to the system.
+   Plane nodes must be sequential starting with reg = <0> as DT parsing
+   will stop on the first missing numbered node.
+   This means if plane #1 is defined but plane #0 is not then it will
+   be as if none of the plane nodes were defined.
+
+   Each plane node contains the following properties:
+   Required properties:
+   - reg:   Used to identify the plane
+   - video-pipelines: One or two HW pipeline number(s).
+   When 2 numbers are present this indicates a virtual wide
+   plane composed of two physical planes intended to be used
+   when the display is larger then the capacity of a
+   single plane i.e. wider than 2048 pixels.
+   The first number in the pair will dictate the capabilities
+   of the plane. This means that for proper
+   operation the virtual plane should be composed of HW
+   planes of the same capabilities.
+   If GFX pipeline is used in a virtual plane it should be
+   specified first, otherwise unexpected behavior would
+   be encountered.
+   Optional property:
+   - video-outputs:  One or more HW output number(s).
+   Describe the list of video output on which this plane
+   is available. If this node is not present then the
+   plane will be available on all available video output.
+
 Video Ports
 ---
 
@@ -216,3 +246,38 @@ OMAP HDMI --(HDMI)--> TPD12S015 --(HDMI)--> HDMI Connector
};
};
 };
+
+A short example on how to define a virtual plane configuration
+to enable wide display support.
+Here we define:
+- plane#0 to be the HW pipeline #0 (i.e. GFX pipeline)
+ only available on video output #0
+- plane#1 to be a virtual wide plane composed of HW pipeline #1 and #2
+ (i.e. VID1 & VID2) available on video output #0 & #1
+- plane#2 to be the HW pipeline #3 (i.e. VID3 pipeline)
+ only available on video output #0
+
+ {
+dispc@58001000 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+plane@0 {
+reg = <0>;
+video-pipelines = <0>;
+video-outputs = <0>;
+};
+
+plane@1 {
+reg = <1>;
+video-pipelines = <1 2>;
+video-outputs = <0 1>;
+};
+
+plane@2 {
+reg = <2>;
+video-pipelines = <3>;
+video-outputs = <0>;
+};
+};
+};
-- 
2.9.0

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


[Patch v2 4/6] drm/omap: Add virtual plane DT parsing support

2018-03-26 Thread Benoit Parrot
Virtual planes are used to extend display size capability for display
larger than 2048 pixels by splitting the frame buffer equally between
two physical video-pipelines.

Here we are adding DT support to parse 'plane' child nodes which
describe how logical planes are mapped to physical video-pipeline(s)
and which video-outputs they are available on.

Signed-off-by: Benoit Parrot <bpar...@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 110 ++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  11 
 2 files changed, 121 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 35541d4441df..06a2e894175e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -4360,6 +4360,115 @@ static u32 dispc_get_memory_bandwidth_limit(void)
return limit;
 }
 
+static struct device_node *dispc_of_get_plane_by_id(struct device_node *node,
+   u32 id)
+{
+   struct device_node *plane;
+
+   for_each_child_of_node(node, plane) {
+   u32 plane_id = 0;
+
+   if (of_node_cmp(plane->name, "plane") != 0)
+   continue;
+   of_property_read_u32(plane, "reg", _id);
+   if (id == plane_id)
+   return plane;
+   }
+
+   return NULL;
+}
+
+static int dispc_parse_dt_plane_data(struct dispc_plane_mappings *map)
+{
+   struct platform_device *pdev = dispc.pdev;
+   struct device_node *np = pdev->dev.of_node;
+   struct device_node *ep;
+   struct property *prop;
+   const __be32 *cur;
+   u32 v;
+   u32 num_ovls = dispc_get_num_ovls();
+   u32 hw_plane_mask = 0;
+   u32 num_planes;
+   int i, index;
+
+   if (!np)
+   return 0;
+
+   for (i = 0; i < num_ovls; i++) {
+   ep = dispc_of_get_plane_by_id(np, i);
+   if (!ep)
+   break;
+   if (!of_property_read_bool(ep, "video-pipelines")) {
+   dev_err(>dev,
+   "malformed plane node: video-pipelines 
missing.\n");
+   return -EINVAL;
+   }
+
+   index = 0;
+   of_property_for_each_u32(ep, "video-pipelines", prop, cur, v) {
+   if (v >= num_ovls) {
+   dev_err(>dev,
+   "video-pipelines property: '%d' 
out-of-range.\n",
+   v);
+   return -EINVAL;
+   }
+   if (hw_plane_mask & BIT_MASK(v)) {
+   dev_err(>dev,
+   "video-pipelines property: '%d' used 
more than once.\n",
+   v);
+   return -EINVAL;
+   }
+   hw_plane_mask |= BIT(v);
+
+   if (index == 0) {
+   map->plane[i].main_id = v;
+   } else if (index == 1) {
+   map->plane[i].aux_id = v;
+   map->plane[i].is_virtual = true;
+   } else if (index > 1) {
+   dev_err(>dev,
+   "video-pipelines property: more than 2 
values specified.\n");
+   return -EINVAL;
+   }
+   index++;
+   }
+
+   of_property_for_each_u32(ep, "video-outputs", prop, cur, v) {
+   if (v >= dispc_get_num_mgrs()) {
+   dev_err(>dev,
+   "video-outputs property: '%d' 
out-of-range.\n",
+   v);
+   return -EINVAL;
+   }
+   map->plane[i].crtc_mask |= BIT(v);
+   }
+   }
+
+   num_planes = i;
+
+   if (num_planes) {
+   dev_dbg(>dev, "Plane definitions found from DT:");
+   for (i = 0; i < num_planes; i++) {
+   if (map->plane[i].is_virtual) {
+   dev_dbg(>dev,
+   "plane%d: virtual video-pipelines: %d, 
%d video-output mask: 0x%04x",
+   i, map->plane[i].main_id,
+   map->plane[i].aux_id,
+   map->plane[i].crtc_mask);
+   } else {
+   dev_dbg(>dev,
+ 

[Patch v2 2/6] dt-bindings: display/ti: Move common dispc bindings to omap-dss.txt

2018-03-26 Thread Benoit Parrot
Add common DISPC bindings into the top level bindings file.
Move common bindings here instead of having multiple copies of
the same information in all of the variant specific files.

Signed-off-by: Benoit Parrot <bpar...@ti.com>
Reviewed-by: Rob Herring <r...@kernel.org>
---
 Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt  | 5 -
 Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt  | 7 +++
 Documentation/devicetree/bindings/display/ti/ti,omap2-dss.txt | 4 
 Documentation/devicetree/bindings/display/ti/ti,omap3-dss.txt | 4 
 Documentation/devicetree/bindings/display/ti/ti,omap4-dss.txt | 4 
 Documentation/devicetree/bindings/display/ti/ti,omap5-dss.txt | 4 
 6 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt
index 91279f1060fe..c30f9ec189ed 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt
@@ -47,11 +47,6 @@ Required properties:
 - clocks: handle to fclk
 - clock-names: "fck"
 
-Optional properties:
-- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
-   in bytes per second
-
-
 HDMI
 
 
diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
index e1ef29569338..249e588d7865 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
@@ -21,6 +21,13 @@ a RGB pixel stream to encoders.
 The encoder modules encode the received RGB pixel stream to a video output like
 HDMI, MIPI DPI, etc.
 
+DISPC
+-
+
+Optional properties:
+- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
+   in bytes per second
+
 Video Ports
 ---
 
diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap2-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,omap2-dss.txt
index ee867c4d1152..afcd5a86c6a4 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,omap2-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,omap2-dss.txt
@@ -28,10 +28,6 @@ Required properties:
 - ti,hwmods: "dss_dispc"
 - interrupts: the DISPC interrupt
 
-Optional properties:
-- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
-   in bytes per second
-
 
 RFBI
 
diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap3-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,omap3-dss.txt
index cd02516a40b6..dc66e1447c31 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,omap3-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,omap3-dss.txt
@@ -37,10 +37,6 @@ Required properties:
 - clocks: handle to fclk
 - clock-names: "fck"
 
-Optional properties:
-- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
-   in bytes per second
-
 
 RFBI
 
diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap4-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,omap4-dss.txt
index 0f85f6b3a5a8..bc624dbd 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,omap4-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,omap4-dss.txt
@@ -36,10 +36,6 @@ Required properties:
 - clocks: handle to fclk
 - clock-names: "fck"
 
-Optional properties:
-- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
-   in bytes per second
-
 
 RFBI
 
diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap5-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,omap5-dss.txt
index 20861218649f..118a486c47bb 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,omap5-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,omap5-dss.txt
@@ -36,10 +36,6 @@ Required properties:
 - clocks: handle to fclk
 - clock-names: "fck"
 
-Optional properties:
-- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
-   in bytes per second
-
 
 RFBI
 
-- 
2.9.0

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


[Patch v2 6/6] drm/omap: Allow wider display when a virtual plane is available

2018-03-26 Thread Benoit Parrot
Add an exception case when filtering out display mode so that if
a virtual wide plane is available then display wider than 2048 can be
supported as long as the required timing parameters can also be met.

Signed-off-by: Benoit Parrot <bpar...@ti.com>
---
 drivers/gpu/drm/omapdrm/omap_connector.c |  3 ++-
 drivers/gpu/drm/omapdrm/omap_plane.c | 12 
 drivers/gpu/drm/omapdrm/omap_plane.h |  1 +
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c 
b/drivers/gpu/drm/omapdrm/omap_connector.c
index d5e059abb555..517f7fa80ce1 100644
--- a/drivers/gpu/drm/omapdrm/omap_connector.c
+++ b/drivers/gpu/drm/omapdrm/omap_connector.c
@@ -203,7 +203,8 @@ static int omap_connector_mode_valid(struct drm_connector 
*connector,
u16 width, height;
 
priv->dispc_ops->ovl_get_max_size(, );
-   if (mode->hdisplay > width)
+   if (mode->hdisplay > width &&
+   !omap_have_any_virtual_plane(dev))
r = -EINVAL;
}
 
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c 
b/drivers/gpu/drm/omapdrm/omap_plane.c
index 21c927bbf5a7..8529abdcdeb8 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -209,6 +209,18 @@ bool is_omap_plane_virtual(struct drm_plane *plane)
return omap_plane->virtual_plane;
 }
 
+bool omap_have_any_virtual_plane(struct drm_device *dev)
+{
+   struct drm_plane *plane;
+
+   drm_for_each_plane(plane, dev) {
+   if (is_omap_plane_virtual(plane))
+   return true;
+   }
+
+   return false;
+}
+
 /* helper to install properties which are common to planes and crtcs */
 void omap_plane_install_properties(struct drm_plane *plane,
struct drm_mode_object *obj)
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.h 
b/drivers/gpu/drm/omapdrm/omap_plane.h
index 48815a05f4fe..86b1c2022231 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.h
+++ b/drivers/gpu/drm/omapdrm/omap_plane.h
@@ -35,5 +35,6 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
 void omap_plane_install_properties(struct drm_plane *plane,
struct drm_mode_object *obj);
 bool is_omap_plane_virtual(struct drm_plane *plane);
+bool omap_have_any_virtual_plane(struct drm_device *dev);
 
 #endif /* __OMAPDRM_PLANE_H__ */
-- 
2.9.0

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


[Patch v2 1/6] drm/omap: Add ability to filter out modes which can't be supported

2018-03-26 Thread Benoit Parrot
Currently available display mode from a connector are filtered out
based only on pixel clock capability. However we also need to filter
out wider mode if we cannot handle them based on available pipeline
capabilities.

Signed-off-by: Benoit Parrot <bpar...@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c  | 27 +++
 drivers/gpu/drm/omapdrm/dss/omapdss.h|  1 +
 drivers/gpu/drm/omapdrm/omap_connector.c | 10 ++
 3 files changed, 38 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 624dee22f46b..35541d4441df 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -100,6 +100,8 @@ struct dispc_features {
u8 mgr_height_start;
u16 mgr_width_max;
u16 mgr_height_max;
+   u16 ovl_width_max;
+   u16 ovl_height_max;
unsigned long max_lcd_pclk;
unsigned long max_tv_pclk;
unsigned int max_downscale;
@@ -2465,6 +2467,12 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, 
unsigned long lclk,
return 0;
 }
 
+static void dispc_ovl_get_max_size(u16 *width, u16 *height)
+{
+   *width = dispc.feat->ovl_width_max;
+   *height = dispc.feat->ovl_height_max;
+}
+
 static int dispc_ovl_setup_common(enum omap_plane_id plane,
enum omap_overlay_caps caps, u32 paddr, u32 p_uv_addr,
u16 screen_width, int pos_x, int pos_y, u16 width, u16 height,
@@ -2500,6 +2508,10 @@ static int dispc_ovl_setup_common(enum omap_plane_id 
plane,
out_width = out_width == 0 ? width : out_width;
out_height = out_height == 0 ? height : out_height;
 
+   WARN(out_width > dispc.feat->ovl_width_max,
+"Requested OVL width (%d) is larger than can be supported (%d).\n",
+out_width, dispc.feat->ovl_width_max);
+
if (ilace && height == out_height)
fieldmode = true;
 
@@ -4043,6 +4055,8 @@ static const struct dispc_features omap24xx_dispc_feats = 
{
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   6650,
.max_downscale  =   2,
/*
@@ -4080,6 +4094,8 @@ static const struct dispc_features 
omap34xx_rev1_0_dispc_feats = {
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17300,
.max_tv_pclk=   5900,
.max_downscale  =   4,
@@ -4114,6 +4130,8 @@ static const struct dispc_features 
omap34xx_rev3_0_dispc_feats = {
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17300,
.max_tv_pclk=   5900,
.max_downscale  =   4,
@@ -4148,6 +4166,8 @@ static const struct dispc_features omap36xx_dispc_feats = 
{
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17300,
.max_tv_pclk=   5900,
.max_downscale  =   4,
@@ -4182,6 +4202,8 @@ static const struct dispc_features am43xx_dispc_feats = {
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17300,
.max_tv_pclk=   5900,
.max_downscale  =   4,
@@ -4216,6 +4238,8 @@ static const struct dispc_features omap44xx_dispc_feats = 
{
.mgr_height_start   =   26,
.mgr_width_max  =   2048,
.mgr_height_max =   2048,
+   .ovl_width_max  =   2048,
+   .ovl_height_max =   2048,
.max_lcd_pclk   =   17000,
.max_tv_pclk=   185625000,
.max_downscale  =   4,
@@ -4255,6 +4279,8 @@ static const struct dispc_features omap54xx_dispc_feats = 
{
.mgr_height_start   =   27,
.mgr_width_max  =   4096,
.mgr_height_max =   4096,
+   .ovl_width_max  =   2048,
+   .ovl_height_max 

[Patch v2 0/6] drm/omap: Add virtual-planes support

2018-03-26 Thread Benoit Parrot
This patch series adds virtual-plane support to omapdrm driver
to allow the use of display wider than 2048 pixels.

The DT bindings are also cleaned up to remove duplication when
properties are common to all implementations.

This patch series depends on Peter Ujfalusi's normalized zpos patch
set which can be found starting here:
  https://patchwork.kernel.org/patch/10299041/

Changes since v1:
- Added a check to filter out unsupportable display mode based on size
- Added Rob reviewed-by for patch #2
- Improve description of patch #3 replace term to remove DRM references
  and use terminology consistent with the Technical Reference Manual 
- Fix the reported zpos issue by reusing and locally extending the
  normalized zpos handling.
- Addressed Tomi's review comments

Benoit Parrot (6):
  drm/omap: Add ability to filter out modes which can't be supported
  dt-bindings: display/ti: Move common dispc bindings to omap-dss.txt
  dt-bindings: display/ti: Add plane binding to dispc node
  drm/omap: Add virtual plane DT parsing support
  drm/omap: Add virtual plane support to omap_plane
  drm/omap: Allow wider display when a virtual plane is available

 .../devicetree/bindings/display/ti/ti,dra7-dss.txt |   5 -
 .../devicetree/bindings/display/ti/ti,omap-dss.txt |  72 +
 .../bindings/display/ti/ti,omap2-dss.txt   |   4 -
 .../bindings/display/ti/ti,omap3-dss.txt   |   4 -
 .../bindings/display/ti/ti,omap4-dss.txt   |   4 -
 .../bindings/display/ti/ti,omap5-dss.txt   |   4 -
 drivers/gpu/drm/omapdrm/dss/dispc.c| 137 +
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  12 ++
 drivers/gpu/drm/omapdrm/omap_connector.c   |  11 ++
 drivers/gpu/drm/omapdrm/omap_drv.c | 127 +++-
 drivers/gpu/drm/omapdrm/omap_fb.c  |  66 ++---
 drivers/gpu/drm/omapdrm/omap_fb.h  |   4 +-
 drivers/gpu/drm/omapdrm/omap_plane.c   | 163 -
 drivers/gpu/drm/omapdrm/omap_plane.h   |   5 +-
 14 files changed, 528 insertions(+), 90 deletions(-)

-- 
2.9.0

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


Re: [Patch 2/4] dt-bindings: display/ti: Add plane binding to dispc node

2018-03-09 Thread Benoit Parrot
Rob Herring <robh...@kernel.org> wrote on Fri [2018-Mar-02 13:19:13 -0600]:
> On Fri, Mar 2, 2018 at 7:48 AM, Benoit Parrot <bpar...@ti.com> wrote:
> > Add 'plane' child node to generic DISPC node as an optional
> > property.
> 
> Why? What problem are you solving?

Ah yes, I guess on its own it does not mean much...

How about:

Currently all available display pipelines (i.e. plane) and output
port resources are exposed to user-space.
In some cases it is needed to be able restrict which resources are
actually visible from user-space. Also in cases where a display wider
than 2048 pixels is to be supported more than one video pipeline is
needed. In this case the 2nd hardware pipeline needed is not visible
to user space applications.

These video pipeline definitions must be statically defined so that
the number of visible pipelines does not change from the user-space
perspective.

In order to allow this we are adding an optional sub-node to the generic
DISPC node. 

> 
> >
> > Signed-off-by: Benoit Parrot <bpar...@ti.com>
> > ---
> >  .../devicetree/bindings/display/ti/ti,omap-dss.txt | 63 
> > ++
> >  1 file changed, 63 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt 
> > b/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
> > index 249e588d7865..cb101525b805 100644
> > --- a/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
> > +++ b/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
> > @@ -27,6 +27,34 @@ DISPC
> >  Optional properties:
> >  - max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
> > limit
> > in bytes per second
> > +- plane: Child node(s) which defines which logical plane are available to
> 
> This is the "Optional properties" section and plane is not a property.

Right, I'll correct that to an optional sub-node which has required and
optional properties.

> 
> > +   the system. If at least one plane child node is defined then
> > +   only planes defined by these nodes will be available to the system.
> > +   Plane nodes must be sequential starting with reg = <0> as DT parsing
> > +   will stop on the first missing numbered node.
> > +   This means if plane #1 is defined but plane #0 is not then it will
> > +   be as if none of the plane nodes were defined.
> > +
> > +   Each plane node contains the following properties:
> > +   Required properties:
> > +   - reg:   Used to number the logical plane
> 
> Is logical plane a h/w concept?

It does represent a hardware resource.

> 
> > +   - hw-planes: One or two HW plane number(s).
> > +When 2 numbers are present this indicates a virtual 
> > plane
> > +composed of two physical planes intended to be used
> > +when the display is larger then the capacity of a
> > +single plane i.e. wider than 2048 pixels.
> > +The first number in the pair will dictate the 
> > capabilities
> > +of the virtual plane. This means that for proper
> > +operation the virtual plane should be composed of HW
> > +planes of the same capabilities.
> > +If GFX plane is used in a virtual plane it should be
> > +specified first, otherwise unexpected behavior would
> > +be encountered.
> > +   Optional property:
> > +   - hw-crtcs:  One or more HW crtc number(s).
> > +Describe the list of CRTCs on which this plane is
> > +available. If this node is not present then the
> > +plane will be available on all available CRTCs.
> 
> Let's not copy archaic terms from DRM into bindings.

Ok, I can rename them to use the TRM terminology instead.
I chose DRM term because they are well known.
So we'll have

video-pipeline instead of hw-planes
video-output instead of hw-crtcs

Any comments on the sub-node name itself?
Or can we keep 'plane'?

> 
> Really, I'm skeptical that any of this belongs in DT. For example,
> can't you figure out you need 2 physical planes whenever your
> panel/timing width is greater than 2048?

As stated in the description I added above, we cannot have resources
exposed to user-space which can "disappear" dynamically.
Doing so would break user-space applications which rely on these
resources.

Benoit

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


[Patch 4/4] drm/omap: Add virtual plane support to omap_plane

2018-03-02 Thread Benoit Parrot
Add virtual plane support by adding an array to contain
all of the actual plane_id a "omap_plane" correspond to.

When at least one 'plane' child node is present in DT then
omap_plane_init will only used the plane described in DT.
Some of these nodes may be a virtual plane if they are defined
as two physical planes.
Planes can also be associated with various crtcs independently.
Therefore we can restrict the use of virtual plane to specific
CRTC/video port if need be, if crtc_mask is not specified then
the plane will be available to all available crtcs.
Physical plane which are not described will essentially be hidden
from the driver.

If no 'plane' child node exist then the existing plane
allocation will take place.

Signed-off-by: Benoit Parrot <bpar...@ti.com>
---
 drivers/gpu/drm/omapdrm/omap_drv.c   |  18 +++--
 drivers/gpu/drm/omapdrm/omap_fb.c|  66 +++--
 drivers/gpu/drm/omapdrm/omap_fb.h|   4 +-
 drivers/gpu/drm/omapdrm/omap_plane.c | 139 +--
 drivers/gpu/drm/omapdrm/omap_plane.h |   3 +-
 5 files changed, 162 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index dd68b2556f5b..73796364a592 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -188,10 +188,9 @@ static int omap_connect_dssdevs(void)
return r;
 }
 
-static int omap_modeset_init_properties(struct drm_device *dev)
+static int omap_modeset_init_properties(struct drm_device *dev, u32 num_planes)
 {
struct omap_drm_private *priv = dev->dev_private;
-   unsigned int num_planes = priv->dispc_ops->get_num_ovls();
 
priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0,
  num_planes - 1);
@@ -210,10 +209,19 @@ static int omap_modeset_init(struct drm_device *dev)
int num_crtcs, crtc_idx, plane_idx;
int ret;
u32 plane_crtc_mask;
+   struct dispc_plane_mappings plane_mappings = {0};
 
drm_mode_config_init(dev);
 
-   ret = omap_modeset_init_properties(dev);
+   ret = priv->dispc_ops->get_plane_mapping(_mappings);
+   if (ret < 0)
+   return ret;
+
+   /* use plane mappings info */
+   if (plane_mappings.num_planes)
+   num_ovls = plane_mappings.num_planes;
+
+   ret = omap_modeset_init_properties(dev, num_ovls);
if (ret < 0)
return ret;
 
@@ -266,7 +274,7 @@ static int omap_modeset_init(struct drm_device *dev)
return -ENOMEM;
 
plane = omap_plane_init(dev, plane_idx, DRM_PLANE_TYPE_PRIMARY,
-   plane_crtc_mask);
+   plane_crtc_mask, _mappings);
if (IS_ERR(plane))
return PTR_ERR(plane);
 
@@ -296,7 +304,7 @@ static int omap_modeset_init(struct drm_device *dev)
return -EINVAL;
 
plane = omap_plane_init(dev, plane_idx, DRM_PLANE_TYPE_OVERLAY,
-   plane_crtc_mask);
+   plane_crtc_mask, _mappings);
if (IS_ERR(plane))
return PTR_ERR(plane);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c 
b/drivers/gpu/drm/omapdrm/omap_fb.c
index b2539a90e1a4..80b29b7f5696 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -153,25 +153,27 @@ static uint32_t drm_rotation_to_tiler(unsigned int 
drm_rot)
 /* update ovl info for scanout, handles cases of multi-planar fb's, etc.
  */
 void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
-   struct drm_plane_state *state, struct omap_overlay_info *info)
+   struct drm_plane_state *state,
+   struct omap_overlay_info *main_info,
+   struct omap_overlay_info *aux_info)
 {
struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
const struct drm_format_info *format = omap_fb->format;
struct plane *plane = _fb->planes[0];
uint32_t x, y, orient = 0;
 
-   info->fourcc = fb->format->format;
+   main_info->fourcc = fb->format->format;
 
-   info->pos_x  = state->crtc_x;
-   info->pos_y  = state->crtc_y;
-   info->out_width  = state->crtc_w;
-   info->out_height = state->crtc_h;
-   info->width  = state->src_w >> 16;
-   info->height = state->src_h >> 16;
+   main_info->pos_x  = state->crtc_x;
+   main_info->pos_y  = state->crtc_y;
+   main_info->out_width  = state->crtc_w;
+   main_info->out_height = state->crtc_h;
+   main_info->width  = state->src_w >> 16;
+   main_info->height = state->src_h >>

[Patch 2/4] dt-bindings: display/ti: Add plane binding to dispc node

2018-03-02 Thread Benoit Parrot
Add 'plane' child node to generic DISPC node as an optional
property.

Signed-off-by: Benoit Parrot <bpar...@ti.com>
---
 .../devicetree/bindings/display/ti/ti,omap-dss.txt | 63 ++
 1 file changed, 63 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
index 249e588d7865..cb101525b805 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
@@ -27,6 +27,34 @@ DISPC
 Optional properties:
 - max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
in bytes per second
+- plane: Child node(s) which defines which logical plane are available to
+   the system. If at least one plane child node is defined then
+   only planes defined by these nodes will be available to the system.
+   Plane nodes must be sequential starting with reg = <0> as DT parsing
+   will stop on the first missing numbered node.
+   This means if plane #1 is defined but plane #0 is not then it will
+   be as if none of the plane nodes were defined.
+
+   Each plane node contains the following properties:
+   Required properties:
+   - reg:   Used to number the logical plane
+   - hw-planes: One or two HW plane number(s).
+When 2 numbers are present this indicates a virtual plane
+composed of two physical planes intended to be used
+when the display is larger then the capacity of a
+single plane i.e. wider than 2048 pixels.
+The first number in the pair will dictate the capabilities
+of the virtual plane. This means that for proper
+operation the virtual plane should be composed of HW
+planes of the same capabilities.
+If GFX plane is used in a virtual plane it should be
+specified first, otherwise unexpected behavior would
+be encountered.
+   Optional property:
+   - hw-crtcs:  One or more HW crtc number(s).
+Describe the list of CRTCs on which this plane is
+available. If this node is not present then the
+plane will be available on all available CRTCs.
 
 Video Ports
 ---
@@ -216,3 +244,38 @@ OMAP HDMI --(HDMI)--> TPD12S015 --(HDMI)--> HDMI Connector
};
};
 };
+
+A short example on how to define a virtual plane configuration
+to enable wide display support.
+Here we define:
+- plane#0 to be the HW plane #0 (i.e. GFX plane)
+ only available on crtc #0
+- plane#1 to be a virtual wide plane composed of HW plane #1 and #2
+ (i.e. VID1 & VID2) available on crtc #0 & #1
+- plane#2 to be the HW plane #3 (i.e. VID3 plane)
+ only available on crtc #0
+
+ {
+dispc@58001000 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+plane@0 {
+reg = <0>;
+hw-planes = <0>;
+hw-crtcs = <0>;
+};
+
+plane@1 {
+reg = <1>;
+hw-planes = <1 2>;
+hw-crtcs = <0 1>;
+};
+
+plane@2 {
+reg = <2>;
+hw-planes = <3>;
+hw-crtcs = <0>;
+};
+};
+};
-- 
2.9.0

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


[Patch 0/4] drm/omap: Add virtual-planes support

2018-03-02 Thread Benoit Parrot
This patch series adds virtual-plane support to omapdrm driver
to allow the use of display wider than 2048 pixels.

The DT bindings are also cleaned up to remove duplication when
properties are common to all implementations.

Benoit Parrot (4):
  dt-bindings: display/ti: Move common dispc bindings to omap-dss.txt
  dt-bindings: display/ti: Add plane binding to dispc node
  drm/omap: Add virtual plane DT parsing support
  drm/omap: Add virtual plane support to omap_plane

 .../devicetree/bindings/display/ti/ti,dra7-dss.txt |   5 -
 .../devicetree/bindings/display/ti/ti,omap-dss.txt |  70 +++
 .../bindings/display/ti/ti,omap2-dss.txt   |   4 -
 .../bindings/display/ti/ti,omap3-dss.txt   |   4 -
 .../bindings/display/ti/ti,omap4-dss.txt   |   4 -
 .../bindings/display/ti/ti,omap5-dss.txt   |   4 -
 drivers/gpu/drm/omapdrm/dss/dispc.c| 110 
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  11 ++
 drivers/gpu/drm/omapdrm/omap_drv.c |  18 ++-
 drivers/gpu/drm/omapdrm/omap_fb.c  |  66 ++
 drivers/gpu/drm/omapdrm/omap_fb.h  |   4 +-
 drivers/gpu/drm/omapdrm/omap_plane.c   | 139 +++--
 drivers/gpu/drm/omapdrm/omap_plane.h   |   3 +-
 13 files changed, 353 insertions(+), 89 deletions(-)

-- 
2.9.0

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


[Patch 3/4] drm/omap: Add virtual plane DT parsing support

2018-03-02 Thread Benoit Parrot
Virtual planes are used to extend display size capability for display
larger than 2048 pixels by splitting the frame buffer equally between
two physical planes.

Here we are adding DT support to parse 'plane' child nodes which
describe how logical planes are mapped to physical plane(s) and
which crtc they are available on.

Signed-off-by: Benoit Parrot <bpar...@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 110 ++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  11 
 2 files changed, 121 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 624dee22f46b..559b70d9762d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -4334,6 +4334,115 @@ static u32 dispc_get_memory_bandwidth_limit(void)
return limit;
 }
 
+static struct device_node *dispc_of_get_plane_by_id(struct device_node *node,
+   u32 id)
+{
+   struct device_node *plane;
+
+   for_each_child_of_node(node, plane) {
+   u32 plane_id = 0;
+
+   if (of_node_cmp(plane->name, "plane") != 0)
+   continue;
+   of_property_read_u32(plane, "reg", _id);
+   if (id == plane_id)
+   break;
+   }
+
+   return plane;
+}
+
+static int dispc_parse_dt_plane_data(struct dispc_plane_mappings *plane)
+{
+   struct platform_device *pdev = dispc.pdev;
+   struct device_node *np = pdev->dev.of_node;
+   struct device_node *ep;
+   struct property *prop;
+   const __be32 *cur;
+   u32 v;
+   u32 num_ovls = dispc_get_num_ovls();
+   unsigned long int hw_plane_mask = (1 << num_ovls) - 1;
+   u32 num_planes;
+   int i, index;
+
+   if (!np)
+   return 0;
+
+   for (i = 0; i < num_ovls; i++) {
+   ep = dispc_of_get_plane_by_id(np, i);
+   if (!ep)
+   break;
+   if (!of_property_read_bool(ep, "hw-planes")) {
+   dev_err(>dev,
+   "malformed plane node: hw-planes missing.\n");
+   return -EINVAL;
+   }
+
+   index = 0;
+   of_property_for_each_u32(ep, "hw-planes", prop, cur, v) {
+   if (v >= num_ovls) {
+   dev_err(>dev,
+   "hw-planes property: '%d' 
out-of-range.\n",
+   v);
+   return -EINVAL;
+   }
+   if (!(hw_plane_mask & BIT_MASK(v))) {
+   dev_err(>dev,
+   "hw-planes property: '%d' used more 
than once.\n",
+   v);
+   return -EINVAL;
+   }
+   clear_bit(v, _plane_mask);
+
+   if (index == 0) {
+   plane->plane[i].main_id = v;
+   } else if (index == 1) {
+   plane->plane[i].aux_id = v;
+   plane->plane[i].is_virtual = true;
+   } else if (index > 1) {
+   dev_err(>dev,
+   "hw-planes property: more than 2 values 
specified.\n");
+   return -EINVAL;
+   }
+   index++;
+   }
+
+   of_property_for_each_u32(ep, "hw-crtcs", prop, cur, v) {
+   if (v >= num_ovls) {
+   dev_err(>dev,
+   "hw-crtcs property: '%d' 
out-of-range.\n",
+   v);
+   return -EINVAL;
+   }
+   plane->plane[i].crtc_mask |= 1 << v;
+   }
+   }
+
+   num_planes = i;
+
+   if (num_planes) {
+   dev_dbg(>dev, "Plane definitions found from DT:");
+   for (i = 0; i < num_planes; i++) {
+   if (plane->plane[i].is_virtual) {
+   dev_dbg(>dev,
+   "plane%d: virtual hw-planes: %d, %d 
crtc_mask: 0x%04x",
+   i, plane->plane[i].main_id,
+   plane->plane[i].aux_id,
+   plane->plane[i].crtc_mask);
+   } else {
+   dev_dbg(>dev,
+  

[Patch 1/4] dt-bindings: display/ti: Move common dispc bindings to omap-dss.txt

2018-03-02 Thread Benoit Parrot
Add common DISPC bindings into the top level bindings file.
Move common bindings here instead of having multiple copies of
the same information in all of the variant specific files.

Signed-off-by: Benoit Parrot <bpar...@ti.com>
---
 Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt  | 5 -
 Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt  | 7 +++
 Documentation/devicetree/bindings/display/ti/ti,omap2-dss.txt | 4 
 Documentation/devicetree/bindings/display/ti/ti,omap3-dss.txt | 4 
 Documentation/devicetree/bindings/display/ti/ti,omap4-dss.txt | 4 
 Documentation/devicetree/bindings/display/ti/ti,omap5-dss.txt | 4 
 6 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt
index 91279f1060fe..c30f9ec189ed 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,dra7-dss.txt
@@ -47,11 +47,6 @@ Required properties:
 - clocks: handle to fclk
 - clock-names: "fck"
 
-Optional properties:
-- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
-   in bytes per second
-
-
 HDMI
 
 
diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
index e1ef29569338..249e588d7865 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,omap-dss.txt
@@ -21,6 +21,13 @@ a RGB pixel stream to encoders.
 The encoder modules encode the received RGB pixel stream to a video output like
 HDMI, MIPI DPI, etc.
 
+DISPC
+-
+
+Optional properties:
+- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
+   in bytes per second
+
 Video Ports
 ---
 
diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap2-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,omap2-dss.txt
index ee867c4d1152..afcd5a86c6a4 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,omap2-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,omap2-dss.txt
@@ -28,10 +28,6 @@ Required properties:
 - ti,hwmods: "dss_dispc"
 - interrupts: the DISPC interrupt
 
-Optional properties:
-- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
-   in bytes per second
-
 
 RFBI
 
diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap3-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,omap3-dss.txt
index cd02516a40b6..dc66e1447c31 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,omap3-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,omap3-dss.txt
@@ -37,10 +37,6 @@ Required properties:
 - clocks: handle to fclk
 - clock-names: "fck"
 
-Optional properties:
-- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
-   in bytes per second
-
 
 RFBI
 
diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap4-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,omap4-dss.txt
index 0f85f6b3a5a8..bc624dbd 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,omap4-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,omap4-dss.txt
@@ -36,10 +36,6 @@ Required properties:
 - clocks: handle to fclk
 - clock-names: "fck"
 
-Optional properties:
-- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
-   in bytes per second
-
 
 RFBI
 
diff --git a/Documentation/devicetree/bindings/display/ti/ti,omap5-dss.txt 
b/Documentation/devicetree/bindings/display/ti/ti,omap5-dss.txt
index 20861218649f..118a486c47bb 100644
--- a/Documentation/devicetree/bindings/display/ti/ti,omap5-dss.txt
+++ b/Documentation/devicetree/bindings/display/ti/ti,omap5-dss.txt
@@ -36,10 +36,6 @@ Required properties:
 - clocks: handle to fclk
 - clock-names: "fck"
 
-Optional properties:
-- max-memory-bandwidth: Input memory (from main memory to dispc) bandwidth 
limit
-   in bytes per second
-
 
 RFBI
 
-- 
2.9.0

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


Re: [PATCH v3 1/1] ARM: dts: AM33XX: Add LCDC info into am335x-evm

2013-09-25 Thread Benoit Parrot
Hi Benoit,

On Tue, Sep 24, 2013 at 11:29:51AM +0200, Benoit Cousson wrote:
 Hi Benoit,
 
 On 03/09/2013 16:55, Benoit Parrot wrote:
 Hi,
 
 I have not received any feedback on this patch.
 It has been pending since the end of June (first post).
 Can I get an estimate when it will be included/accepted?
 
 It looks good to me beside a minor comment below.
 
 Could you just rebase it on my lastest 
 git://git.kernel.org/pub/scm/linux/kernel/git/bcousson/linux-omap-dt.git
 for_3.13/dts branch because it conflicts with the cleanup done by
 Javier.
 

I was going to rebase it to your for_3.13/dts branch, but Joel Frenandez has 
already included this patch as part of his most recent submission.
(http://marc.info/?l=devicetreem=138014654925217w=2) so I guess there is no
need to duplicate the work now.

Let me know if this causes any issue.

Thanks,
Benoit

 
 On Fri, Aug 23, 2013 at 11:13:56AM -0500, Benoit Parrot wrote:
 Add LCDC device node in DT for am33xx
 Add LCDC and Panel info in DT for am335x-evm
 
 Changes in v3:
 - rebase to 3.11-rc6
 
 Changes in v2:
 - remove redundant/unnecessary SoC specific setting in the board dts
 
 Signed-off-by: Benoit Parrot bpar...@ti.com
 ---
   arch/arm/boot/dts/am335x-evm.dts |   72 
  ++
   arch/arm/boot/dts/am33xx.dtsi|9 +
   2 files changed, 81 insertions(+)
 
 diff --git a/arch/arm/boot/dts/am335x-evm.dts 
 b/arch/arm/boot/dts/am335x-evm.dts
 index 3aee1a4..b0703f1 100644
 --- a/arch/arm/boot/dts/am335x-evm.dts
 +++ b/arch/arm/boot/dts/am335x-evm.dts
 @@ -149,6 +149,40 @@
 0x14c (PIN_INPUT_PULLDOWN | MUX_MODE7)
 ;
 };
 +
 +   lcd_pins_s0: lcd_pins_s0 {
 +   pinctrl-single,pins = 
 +   0x20 0x01   /* gpmc_ad8.lcd_data16, OUTPUT 
 | MODE1 */
 +   0x24 0x01   /* gpmc_ad9.lcd_data17, OUTPUT 
 | MODE1 */
 +   0x28 0x01   /* gpmc_ad10.lcd_data18, OUTPUT 
 | MODE1 */
 +   0x2c 0x01   /* gpmc_ad11.lcd_data19, OUTPUT 
 | MODE1 */
 +   0x30 0x01   /* gpmc_ad12.lcd_data20, OUTPUT 
 | MODE1 */
 +   0x34 0x01   /* gpmc_ad13.lcd_data21, OUTPUT 
 | MODE1 */
 +   0x38 0x01   /* gpmc_ad14.lcd_data22, OUTPUT 
 | MODE1 */
 +   0x3c 0x01   /* gpmc_ad15.lcd_data23, OUTPUT 
 | MODE1 */
 +   0xa0 0x00   /* lcd_data0.lcd_data0, OUTPUT 
 | MODE0 */
 +   0xa4 0x00   /* lcd_data1.lcd_data1, OUTPUT 
 | MODE0 */
 +   0xa8 0x00   /* lcd_data2.lcd_data2, OUTPUT 
 | MODE0 */
 +   0xac 0x00   /* lcd_data3.lcd_data3, OUTPUT 
 | MODE0 */
 +   0xb0 0x00   /* lcd_data4.lcd_data4, OUTPUT 
 | MODE0 */
 +   0xb4 0x00   /* lcd_data5.lcd_data5, OUTPUT 
 | MODE0 */
 +   0xb8 0x00   /* lcd_data6.lcd_data6, OUTPUT 
 | MODE0 */
 +   0xbc 0x00   /* lcd_data7.lcd_data7, OUTPUT 
 | MODE0 */
 +   0xc0 0x00   /* lcd_data8.lcd_data8, OUTPUT 
 | MODE0 */
 +   0xc4 0x00   /* lcd_data9.lcd_data9, OUTPUT 
 | MODE0 */
 +   0xc8 0x00   /* lcd_data10.lcd_data10, 
 OUTPUT | MODE0 */
 +   0xcc 0x00   /* lcd_data11.lcd_data11, 
 OUTPUT | MODE0 */
 +   0xd0 0x00   /* lcd_data12.lcd_data12, 
 OUTPUT | MODE0 */
 +   0xd4 0x00   /* lcd_data13.lcd_data13, 
 OUTPUT | MODE0 */
 +   0xd8 0x00   /* lcd_data14.lcd_data14, 
 OUTPUT | MODE0 */
 +   0xdc 0x00   /* lcd_data15.lcd_data15, 
 OUTPUT | MODE0 */
 +   0xe0 0x00   /* lcd_vsync.lcd_vsync, OUTPUT 
 | MODE0 */
 +   0xe4 0x00   /* lcd_hsync.lcd_hsync, OUTPUT 
 | MODE0 */
 +   0xe8 0x00   /* lcd_pclk.lcd_pclk, OUTPUT | 
 MODE0 */
 +   0xec 0x00   /* 
 lcd_ac_bias_en.lcd_ac_bias_en, OUTPUT | MODE0 */
 +   ;
 +   };
 +
 };
 
 ocp {
 @@ -311,6 +345,10 @@
 };
 };
 };
 +
 +   lcdc: lcdc@4830e000 {
 +   status = okay;
 +   };
 };
 
 vbat: fixedregulator@0 {
 @@ -374,6 +412,40 @@
 brightness-levels = 0 51 53 56 62 75 101 152 255;
 default-brightness-level = 8;
 };
 +
 +   panel {
 +   compatible = ti,tilcdc,panel;
 
 Nit: There are a lots of TI here :-)
 Could you just name it: ti,lcdc,panel ?
 
 Thanks,
 Benoit
 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http

Re: [PATCH v3 1/1] ARM: dts: AM33XX: Add LCDC info into am335x-evm

2013-09-03 Thread Benoit Parrot
Hi,

I have not received any feedback on this patch.
It has been pending since the end of June (first post).
Can I get an estimate when it will be included/accepted?

Thanks,
Benoit


On Fri, Aug 23, 2013 at 11:13:56AM -0500, Benoit Parrot wrote:
 Add LCDC device node in DT for am33xx
 Add LCDC and Panel info in DT for am335x-evm
 
 Changes in v3:
 - rebase to 3.11-rc6
 
 Changes in v2:
 - remove redundant/unnecessary SoC specific setting in the board dts
 
 Signed-off-by: Benoit Parrot bpar...@ti.com
 ---
  arch/arm/boot/dts/am335x-evm.dts |   72 
 ++
  arch/arm/boot/dts/am33xx.dtsi|9 +
  2 files changed, 81 insertions(+)
 
 diff --git a/arch/arm/boot/dts/am335x-evm.dts 
 b/arch/arm/boot/dts/am335x-evm.dts
 index 3aee1a4..b0703f1 100644
 --- a/arch/arm/boot/dts/am335x-evm.dts
 +++ b/arch/arm/boot/dts/am335x-evm.dts
 @@ -149,6 +149,40 @@
   0x14c (PIN_INPUT_PULLDOWN | MUX_MODE7)
   ;
   };
 +
 + lcd_pins_s0: lcd_pins_s0 {
 + pinctrl-single,pins = 
 + 0x20 0x01   /* gpmc_ad8.lcd_data16, OUTPUT 
 | MODE1 */
 + 0x24 0x01   /* gpmc_ad9.lcd_data17, OUTPUT 
 | MODE1 */
 + 0x28 0x01   /* gpmc_ad10.lcd_data18, OUTPUT 
 | MODE1 */
 + 0x2c 0x01   /* gpmc_ad11.lcd_data19, OUTPUT 
 | MODE1 */
 + 0x30 0x01   /* gpmc_ad12.lcd_data20, OUTPUT 
 | MODE1 */
 + 0x34 0x01   /* gpmc_ad13.lcd_data21, OUTPUT 
 | MODE1 */
 + 0x38 0x01   /* gpmc_ad14.lcd_data22, OUTPUT 
 | MODE1 */
 + 0x3c 0x01   /* gpmc_ad15.lcd_data23, OUTPUT 
 | MODE1 */
 + 0xa0 0x00   /* lcd_data0.lcd_data0, OUTPUT 
 | MODE0 */
 + 0xa4 0x00   /* lcd_data1.lcd_data1, OUTPUT 
 | MODE0 */
 + 0xa8 0x00   /* lcd_data2.lcd_data2, OUTPUT 
 | MODE0 */
 + 0xac 0x00   /* lcd_data3.lcd_data3, OUTPUT 
 | MODE0 */
 + 0xb0 0x00   /* lcd_data4.lcd_data4, OUTPUT 
 | MODE0 */
 + 0xb4 0x00   /* lcd_data5.lcd_data5, OUTPUT 
 | MODE0 */
 + 0xb8 0x00   /* lcd_data6.lcd_data6, OUTPUT 
 | MODE0 */
 + 0xbc 0x00   /* lcd_data7.lcd_data7, OUTPUT 
 | MODE0 */
 + 0xc0 0x00   /* lcd_data8.lcd_data8, OUTPUT 
 | MODE0 */
 + 0xc4 0x00   /* lcd_data9.lcd_data9, OUTPUT 
 | MODE0 */
 + 0xc8 0x00   /* lcd_data10.lcd_data10, 
 OUTPUT | MODE0 */
 + 0xcc 0x00   /* lcd_data11.lcd_data11, 
 OUTPUT | MODE0 */
 + 0xd0 0x00   /* lcd_data12.lcd_data12, 
 OUTPUT | MODE0 */
 + 0xd4 0x00   /* lcd_data13.lcd_data13, 
 OUTPUT | MODE0 */
 + 0xd8 0x00   /* lcd_data14.lcd_data14, 
 OUTPUT | MODE0 */
 + 0xdc 0x00   /* lcd_data15.lcd_data15, 
 OUTPUT | MODE0 */
 + 0xe0 0x00   /* lcd_vsync.lcd_vsync, OUTPUT 
 | MODE0 */
 + 0xe4 0x00   /* lcd_hsync.lcd_hsync, OUTPUT 
 | MODE0 */
 + 0xe8 0x00   /* lcd_pclk.lcd_pclk, OUTPUT | 
 MODE0 */
 + 0xec 0x00   /* 
 lcd_ac_bias_en.lcd_ac_bias_en, OUTPUT | MODE0 */
 + ;
 + };
 +
   };
  
   ocp {
 @@ -311,6 +345,10 @@
   };
   };
   };
 +
 + lcdc: lcdc@4830e000 {
 + status = okay;
 + };
   };
  
   vbat: fixedregulator@0 {
 @@ -374,6 +412,40 @@
   brightness-levels = 0 51 53 56 62 75 101 152 255;
   default-brightness-level = 8;
   };
 +
 + panel {
 + compatible = ti,tilcdc,panel;
 + status = okay;
 + pinctrl-names = default;
 + pinctrl-0 = lcd_pins_s0;
 + panel-info {
 + ac-bias   = 255;
 + ac-bias-intrpt= 0;
 + dma-burst-sz  = 16;
 + bpp   = 32;
 + fdd   = 0x80;
 + sync-edge = 0;
 + sync-ctrl = 1;
 + raster-order  = 0;
 + fifo-th   = 0;
 + };
 +
 + display-timings {
 + 800x480p62 {
 + clock-frequency = 3000;
 + hactive = 800;
 + vactive = 480

[PATCH v3 1/1] ARM: dts: AM33XX: Add LCDC info into am335x-evm

2013-08-23 Thread Benoit Parrot
Add LCDC device node in DT for am33xx
Add LCDC and Panel info in DT for am335x-evm

Changes in v3:
- rebase to 3.11-rc6

Changes in v2:
- remove redundant/unnecessary SoC specific setting in the board dts

Signed-off-by: Benoit Parrot 
---
 arch/arm/boot/dts/am335x-evm.dts |   72 ++
 arch/arm/boot/dts/am33xx.dtsi|9 +
 2 files changed, 81 insertions(+)

diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts
index 3aee1a4..b0703f1 100644
--- a/arch/arm/boot/dts/am335x-evm.dts
+++ b/arch/arm/boot/dts/am335x-evm.dts
@@ -149,6 +149,40 @@
0x14c (PIN_INPUT_PULLDOWN | MUX_MODE7)
>;
};
+
+   lcd_pins_s0: lcd_pins_s0 {
+   pinctrl-single,pins = <
+   0x20 0x01   /* gpmc_ad8.lcd_data16, OUTPUT 
| MODE1 */
+   0x24 0x01   /* gpmc_ad9.lcd_data17, OUTPUT 
| MODE1 */
+   0x28 0x01   /* gpmc_ad10.lcd_data18, OUTPUT 
| MODE1 */
+   0x2c 0x01   /* gpmc_ad11.lcd_data19, OUTPUT 
| MODE1 */
+   0x30 0x01   /* gpmc_ad12.lcd_data20, OUTPUT 
| MODE1 */
+   0x34 0x01   /* gpmc_ad13.lcd_data21, OUTPUT 
| MODE1 */
+   0x38 0x01   /* gpmc_ad14.lcd_data22, OUTPUT 
| MODE1 */
+   0x3c 0x01   /* gpmc_ad15.lcd_data23, OUTPUT 
| MODE1 */
+   0xa0 0x00   /* lcd_data0.lcd_data0, OUTPUT 
| MODE0 */
+   0xa4 0x00   /* lcd_data1.lcd_data1, OUTPUT 
| MODE0 */
+   0xa8 0x00   /* lcd_data2.lcd_data2, OUTPUT 
| MODE0 */
+   0xac 0x00   /* lcd_data3.lcd_data3, OUTPUT 
| MODE0 */
+   0xb0 0x00   /* lcd_data4.lcd_data4, OUTPUT 
| MODE0 */
+   0xb4 0x00   /* lcd_data5.lcd_data5, OUTPUT 
| MODE0 */
+   0xb8 0x00   /* lcd_data6.lcd_data6, OUTPUT 
| MODE0 */
+   0xbc 0x00   /* lcd_data7.lcd_data7, OUTPUT 
| MODE0 */
+   0xc0 0x00   /* lcd_data8.lcd_data8, OUTPUT 
| MODE0 */
+   0xc4 0x00   /* lcd_data9.lcd_data9, OUTPUT 
| MODE0 */
+   0xc8 0x00   /* lcd_data10.lcd_data10, 
OUTPUT | MODE0 */
+   0xcc 0x00   /* lcd_data11.lcd_data11, 
OUTPUT | MODE0 */
+   0xd0 0x00   /* lcd_data12.lcd_data12, 
OUTPUT | MODE0 */
+   0xd4 0x00   /* lcd_data13.lcd_data13, 
OUTPUT | MODE0 */
+   0xd8 0x00   /* lcd_data14.lcd_data14, 
OUTPUT | MODE0 */
+   0xdc 0x00   /* lcd_data15.lcd_data15, 
OUTPUT | MODE0 */
+   0xe0 0x00   /* lcd_vsync.lcd_vsync, OUTPUT 
| MODE0 */
+   0xe4 0x00   /* lcd_hsync.lcd_hsync, OUTPUT 
| MODE0 */
+   0xe8 0x00   /* lcd_pclk.lcd_pclk, OUTPUT | 
MODE0 */
+   0xec 0x00   /* 
lcd_ac_bias_en.lcd_ac_bias_en, OUTPUT | MODE0 */
+   >;
+   };
+
};

ocp {
@@ -311,6 +345,10 @@
};
};
};
+
+   lcdc: lcdc at 4830e000 {
+   status = "okay";
+   };
};

vbat: fixedregulator at 0 {
@@ -374,6 +412,40 @@
brightness-levels = <0 51 53 56 62 75 101 152 255>;
default-brightness-level = <8>;
};
+
+   panel {
+   compatible = "ti,tilcdc,panel";
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins_s0>;
+   panel-info {
+   ac-bias   = <255>;
+   ac-bias-intrpt= <0>;
+   dma-burst-sz  = <16>;
+   bpp   = <32>;
+   fdd   = <0x80>;
+   sync-edge = <0>;
+   sync-ctrl = <1>;
+   raster-order  = <0>;
+   fifo-th   = <0>;
+   };
+
+   display-timings {
+   800x480p62 {
+   clock-frequency = <3000>;
+   hactive = <800>;
+   vactive = <480>;
+   hfront-porch = <39>;
+ 

[PATCH v3 1/1] ARM: dts: AM33XX: Add LCDC info into am335x-evm

2013-08-23 Thread Benoit Parrot
Add LCDC device node in DT for am33xx
Add LCDC and Panel info in DT for am335x-evm

Changes in v3:
- rebase to 3.11-rc6

Changes in v2:
- remove redundant/unnecessary SoC specific setting in the board dts

Signed-off-by: Benoit Parrot bpar...@ti.com
---
 arch/arm/boot/dts/am335x-evm.dts |   72 ++
 arch/arm/boot/dts/am33xx.dtsi|9 +
 2 files changed, 81 insertions(+)

diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts
index 3aee1a4..b0703f1 100644
--- a/arch/arm/boot/dts/am335x-evm.dts
+++ b/arch/arm/boot/dts/am335x-evm.dts
@@ -149,6 +149,40 @@
0x14c (PIN_INPUT_PULLDOWN | MUX_MODE7)
;
};
+
+   lcd_pins_s0: lcd_pins_s0 {
+   pinctrl-single,pins = 
+   0x20 0x01   /* gpmc_ad8.lcd_data16, OUTPUT 
| MODE1 */
+   0x24 0x01   /* gpmc_ad9.lcd_data17, OUTPUT 
| MODE1 */
+   0x28 0x01   /* gpmc_ad10.lcd_data18, OUTPUT 
| MODE1 */
+   0x2c 0x01   /* gpmc_ad11.lcd_data19, OUTPUT 
| MODE1 */
+   0x30 0x01   /* gpmc_ad12.lcd_data20, OUTPUT 
| MODE1 */
+   0x34 0x01   /* gpmc_ad13.lcd_data21, OUTPUT 
| MODE1 */
+   0x38 0x01   /* gpmc_ad14.lcd_data22, OUTPUT 
| MODE1 */
+   0x3c 0x01   /* gpmc_ad15.lcd_data23, OUTPUT 
| MODE1 */
+   0xa0 0x00   /* lcd_data0.lcd_data0, OUTPUT 
| MODE0 */
+   0xa4 0x00   /* lcd_data1.lcd_data1, OUTPUT 
| MODE0 */
+   0xa8 0x00   /* lcd_data2.lcd_data2, OUTPUT 
| MODE0 */
+   0xac 0x00   /* lcd_data3.lcd_data3, OUTPUT 
| MODE0 */
+   0xb0 0x00   /* lcd_data4.lcd_data4, OUTPUT 
| MODE0 */
+   0xb4 0x00   /* lcd_data5.lcd_data5, OUTPUT 
| MODE0 */
+   0xb8 0x00   /* lcd_data6.lcd_data6, OUTPUT 
| MODE0 */
+   0xbc 0x00   /* lcd_data7.lcd_data7, OUTPUT 
| MODE0 */
+   0xc0 0x00   /* lcd_data8.lcd_data8, OUTPUT 
| MODE0 */
+   0xc4 0x00   /* lcd_data9.lcd_data9, OUTPUT 
| MODE0 */
+   0xc8 0x00   /* lcd_data10.lcd_data10, 
OUTPUT | MODE0 */
+   0xcc 0x00   /* lcd_data11.lcd_data11, 
OUTPUT | MODE0 */
+   0xd0 0x00   /* lcd_data12.lcd_data12, 
OUTPUT | MODE0 */
+   0xd4 0x00   /* lcd_data13.lcd_data13, 
OUTPUT | MODE0 */
+   0xd8 0x00   /* lcd_data14.lcd_data14, 
OUTPUT | MODE0 */
+   0xdc 0x00   /* lcd_data15.lcd_data15, 
OUTPUT | MODE0 */
+   0xe0 0x00   /* lcd_vsync.lcd_vsync, OUTPUT 
| MODE0 */
+   0xe4 0x00   /* lcd_hsync.lcd_hsync, OUTPUT 
| MODE0 */
+   0xe8 0x00   /* lcd_pclk.lcd_pclk, OUTPUT | 
MODE0 */
+   0xec 0x00   /* 
lcd_ac_bias_en.lcd_ac_bias_en, OUTPUT | MODE0 */
+   ;
+   };
+
};
 
ocp {
@@ -311,6 +345,10 @@
};
};
};
+
+   lcdc: lcdc@4830e000 {
+   status = okay;
+   };
};
 
vbat: fixedregulator@0 {
@@ -374,6 +412,40 @@
brightness-levels = 0 51 53 56 62 75 101 152 255;
default-brightness-level = 8;
};
+
+   panel {
+   compatible = ti,tilcdc,panel;
+   status = okay;
+   pinctrl-names = default;
+   pinctrl-0 = lcd_pins_s0;
+   panel-info {
+   ac-bias   = 255;
+   ac-bias-intrpt= 0;
+   dma-burst-sz  = 16;
+   bpp   = 32;
+   fdd   = 0x80;
+   sync-edge = 0;
+   sync-ctrl = 1;
+   raster-order  = 0;
+   fifo-th   = 0;
+   };
+
+   display-timings {
+   800x480p62 {
+   clock-frequency = 3000;
+   hactive = 800;
+   vactive = 480;
+   hfront-porch = 39;
+   hback-porch = 39;
+   hsync-len = 47;
+   vback-porch = 29;
+   vfront-porch

[PATCH 1/1] gpu:drm:tilcdc: get preferred_bpp value from DT

2013-06-18 Thread Benoit Parrot
The preferred_bpp value in currently hard-coded to 16.
This causes color corruption on the am335x-evm lcd panel which
requires 32 bpp instead. This changes attempts to use the configured
bpp value from the DT or built-in panel-info struct.

Signed-off-by: Benoit Parrot 
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c|   12 +++-
 drivers/gpu/drm/tilcdc/tilcdc_drv.h|1 +
 drivers/gpu/drm/tilcdc/tilcdc_panel.c  |2 ++
 drivers/gpu/drm/tilcdc/tilcdc_slave.c  |2 ++
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c |2 ++
 5 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 2b5461b..f2a6528 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -157,7 +157,9 @@ static int tilcdc_load(struct drm_device *dev, unsigned 
long flags)
struct platform_device *pdev = dev->platformdev;
struct device_node *node = pdev->dev.of_node;
struct tilcdc_drm_private *priv;
+   struct tilcdc_module *mod;
struct resource *res;
+   u32 bpp = 0;
int ret;

priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -256,7 +258,15 @@ static int tilcdc_load(struct drm_device *dev, unsigned 
long flags)

platform_set_drvdata(pdev, dev);

-   priv->fbdev = drm_fbdev_cma_init(dev, 16,
+
+   list_for_each_entry(mod, _list, list) {
+   DBG("%s: preferred_bpp: %d", mod->name, mod->preferred_bpp);
+   bpp = mod->preferred_bpp;
+   if (bpp > 0)
+   break;
+   }
+
+   priv->fbdev = drm_fbdev_cma_init(dev, bpp,
dev->mode_config.num_crtc,
dev->mode_config.num_connector);

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index 8242b5a..0906843 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -89,6 +89,7 @@ struct tilcdc_module {
const char *name;
struct list_head list;
const struct tilcdc_module_ops *funcs;
+   unsigned int preferred_bpp;
 };

 void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c 
b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
index 0917665..86c6732 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
@@ -393,6 +393,8 @@ static int panel_probe(struct platform_device *pdev)
goto fail;
}

+   mod->preferred_bpp = panel_mod->info->bpp;
+
panel_mod->backlight = of_find_backlight_by_node(node);
if (panel_mod->backlight)
dev_info(>dev, "found backlight\n");
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave.c 
b/drivers/gpu/drm/tilcdc/tilcdc_slave.c
index db1d2fc..8bf4fd1 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_slave.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_slave.c
@@ -323,6 +323,8 @@ static int slave_probe(struct platform_device *pdev)
goto fail;
}

+   mod->preferred_bpp = slave_info.bpp;
+
i2c_node = of_find_node_by_phandle(i2c_phandle);
if (!i2c_node) {
dev_err(>dev, "could not get i2c bus node\n");
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c 
b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
index a36788f..925c7cd 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
@@ -354,6 +354,8 @@ static int tfp410_probe(struct platform_device *pdev)
goto fail;
}

+   mod->preferred_bpp = dvi_info.bpp;
+
i2c_node = of_find_node_by_phandle(i2c_phandle);
if (!i2c_node) {
dev_err(>dev, "could not get i2c bus node\n");
-- 
1.7.9.5



[PATCH 1/1] gpu:drm:tilcdc: get preferred_bpp value from DT

2013-06-18 Thread Benoit Parrot
The preferred_bpp value in currently hard-coded to 16.
This causes color corruption on the am335x-evm lcd panel which
requires 32 bpp instead. This changes attempts to use the configured
bpp value from the DT or built-in panel-info struct.

Signed-off-by: Benoit Parrot bpar...@ti.com
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c|   12 +++-
 drivers/gpu/drm/tilcdc/tilcdc_drv.h|1 +
 drivers/gpu/drm/tilcdc/tilcdc_panel.c  |2 ++
 drivers/gpu/drm/tilcdc/tilcdc_slave.c  |2 ++
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c |2 ++
 5 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 2b5461b..f2a6528 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -157,7 +157,9 @@ static int tilcdc_load(struct drm_device *dev, unsigned 
long flags)
struct platform_device *pdev = dev-platformdev;
struct device_node *node = pdev-dev.of_node;
struct tilcdc_drm_private *priv;
+   struct tilcdc_module *mod;
struct resource *res;
+   u32 bpp = 0;
int ret;
 
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -256,7 +258,15 @@ static int tilcdc_load(struct drm_device *dev, unsigned 
long flags)
 
platform_set_drvdata(pdev, dev);
 
-   priv-fbdev = drm_fbdev_cma_init(dev, 16,
+
+   list_for_each_entry(mod, module_list, list) {
+   DBG(%s: preferred_bpp: %d, mod-name, mod-preferred_bpp);
+   bpp = mod-preferred_bpp;
+   if (bpp  0)
+   break;
+   }
+
+   priv-fbdev = drm_fbdev_cma_init(dev, bpp,
dev-mode_config.num_crtc,
dev-mode_config.num_connector);
 
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index 8242b5a..0906843 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -89,6 +89,7 @@ struct tilcdc_module {
const char *name;
struct list_head list;
const struct tilcdc_module_ops *funcs;
+   unsigned int preferred_bpp;
 };
 
 void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c 
b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
index 0917665..86c6732 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
@@ -393,6 +393,8 @@ static int panel_probe(struct platform_device *pdev)
goto fail;
}
 
+   mod-preferred_bpp = panel_mod-info-bpp;
+
panel_mod-backlight = of_find_backlight_by_node(node);
if (panel_mod-backlight)
dev_info(pdev-dev, found backlight\n);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave.c 
b/drivers/gpu/drm/tilcdc/tilcdc_slave.c
index db1d2fc..8bf4fd1 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_slave.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_slave.c
@@ -323,6 +323,8 @@ static int slave_probe(struct platform_device *pdev)
goto fail;
}
 
+   mod-preferred_bpp = slave_info.bpp;
+
i2c_node = of_find_node_by_phandle(i2c_phandle);
if (!i2c_node) {
dev_err(pdev-dev, could not get i2c bus node\n);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c 
b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
index a36788f..925c7cd 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
@@ -354,6 +354,8 @@ static int tfp410_probe(struct platform_device *pdev)
goto fail;
}
 
+   mod-preferred_bpp = dvi_info.bpp;
+
i2c_node = of_find_node_by_phandle(i2c_phandle);
if (!i2c_node) {
dev_err(pdev-dev, could not get i2c bus node\n);
-- 
1.7.9.5

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