Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1615091

Re: [PATCH v3 04/11] drm/sun4i: abstract the layer type

From Chen-Yu Tsai <wens@csie.org>
Newsgroups linux.kernel
Subject Re: [PATCH v3 04/11] drm/sun4i: abstract the layer type
Date 2017-04-03 13:00 +0200
Message-ID <ts7Sh-5KY-13@gated-at.bofh.it> (permalink)
References <tqrLs-34R-5@gated-at.bofh.it> <tqttU-4o9-13@gated-at.bofh.it> <ts5nr-4l0-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Apr 3, 2017 at 4:14 PM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> Hi,
>
> On Thu, Mar 30, 2017 at 03:46:06AM +0800, Icenowy Zheng wrote:
>> As we are going to add support for the Allwinner DE2 Mixer in sun4i-drm
>> driver, we will finally have two types of layer.
>>
>> Abstract the layer type to void * and a ops struct, which contains the
>> only function used by crtc -- get the drm_plane struct of the layer.
>>
>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>> ---
>> Refactored patch in v3.
>>
>>  drivers/gpu/drm/sun4i/sun4i_crtc.c  | 19 +++++++++++--------
>>  drivers/gpu/drm/sun4i/sun4i_crtc.h  |  3 ++-
>>  drivers/gpu/drm/sun4i/sun4i_layer.c | 19 ++++++++++++++++++-
>>  drivers/gpu/drm/sun4i/sun4i_layer.h |  2 +-
>>  drivers/gpu/drm/sun4i/sunxi_layer.h | 17 +++++++++++++++++
>>  5 files changed, 49 insertions(+), 11 deletions(-)
>>  create mode 100644 drivers/gpu/drm/sun4i/sunxi_layer.h
>>
>> diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c b/drivers/gpu/drm/sun4i/sun4i_crtc.c
>> index 3c876c3a356a..33854ee7f636 100644
>> --- a/drivers/gpu/drm/sun4i/sun4i_crtc.c
>> +++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c
>> @@ -29,6 +29,7 @@
>>  #include "sun4i_crtc.h"
>>  #include "sun4i_drv.h"
>>  #include "sun4i_layer.h"
>> +#include "sunxi_layer.h"
>>  #include "sun4i_tcon.h"
>>
>>  static void sun4i_crtc_atomic_begin(struct drm_crtc *crtc,
>> @@ -149,7 +150,7 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm,
>>       scrtc->tcon = tcon;
>>
>>       /* Create our layers */
>> -     scrtc->layers = sun4i_layers_init(drm, scrtc->backend);
>> +     scrtc->layers = (void **)sun4i_layers_init(drm, scrtc);
>>       if (IS_ERR(scrtc->layers)) {
>>               dev_err(drm->dev, "Couldn't create the planes\n");
>>               return NULL;
>> @@ -157,14 +158,15 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm,
>>
>>       /* find primary and cursor planes for drm_crtc_init_with_planes */
>>       for (i = 0; scrtc->layers[i]; i++) {
>> -             struct sun4i_layer *layer = scrtc->layers[i];
>> +             void *layer = scrtc->layers[i];
>> +             struct drm_plane *plane = scrtc->layer_ops->get_plane(layer);
>>
>> -             switch (layer->plane.type) {
>> +             switch (plane->type) {
>>               case DRM_PLANE_TYPE_PRIMARY:
>> -                     primary = &layer->plane;
>> +                     primary = plane;
>>                       break;
>>               case DRM_PLANE_TYPE_CURSOR:
>> -                     cursor = &layer->plane;
>> +                     cursor = plane;
>>                       break;
>>               default:
>>                       break;
>> @@ -190,10 +192,11 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm,
>>       /* Set possible_crtcs to this crtc for overlay planes */
>>       for (i = 0; scrtc->layers[i]; i++) {
>>               uint32_t possible_crtcs = BIT(drm_crtc_index(&scrtc->crtc));
>> -             struct sun4i_layer *layer = scrtc->layers[i];
>> +             void *layer = scrtc->layers[i];
>> +             struct drm_plane *plane = scrtc->layer_ops->get_plane(layer);
>>
>> -             if (layer->plane.type == DRM_PLANE_TYPE_OVERLAY)
>> -                     layer->plane.possible_crtcs = possible_crtcs;
>> +             if (plane->type == DRM_PLANE_TYPE_OVERLAY)
>> +                     plane->possible_crtcs = possible_crtcs;
>
> I think the logic should be reversed here, the CRTC shouldn't care
> (much) about the layers at all.

Correct. It shouldn't. However since the layers are tied to a specific
crtc, they get created as part of the crtc init sequence.

> We should modify sun4i_crtc_init to get the argument it needs (primary
> and cursor planes for example) through its parameters, and have the
> caller (which iirc is sun4i_drv) call it with the right parameters

The caller is (now) sun4i_crtc_init.

> depending on whether you're using DE or DE2.

Ack.

>
> If we're doing that, I don't think we even need the pointer to the
> array of layers in struct sun4i_crtc, which will make it easier to
> deal with.

Ack.

ChenYu

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 00/11] Initial Allwinner Display Engine 2.0 Support Icenowy Zheng <icenowy@aosc.io> - 2017-03-29 21:50 +0200
  [PATCH v3 07/11] drm/sun4i: Add compatible string for V3s display engine Icenowy Zheng <icenowy@aosc.io> - 2017-03-29 22:00 +0200
  [PATCH v3 08/11] drm/sun4i: tcon: add support for V3s TCON Icenowy Zheng <icenowy@aosc.io> - 2017-03-29 22:00 +0200
  [PATCH v3 01/11] dt-bindings: add binding for the Allwinner DE2 CCU Icenowy Zheng <icenowy@aosc.io> - 2017-03-29 22:00 +0200
    Re: [PATCH v3 01/11] dt-bindings: add binding for the Allwinner DE2  CCU Rob Herring <robh@kernel.org> - 2017-04-03 17:40 +0200
  [PATCH v3 09/11] ARM: dts: sun8i: add DE2 nodes for V3s SoC Icenowy Zheng <icenowy@aosc.io> - 2017-03-29 22:10 +0200
  [PATCH v3 10/11] ARM: dts: sun8i: add pinmux for LCD pins of V3s SoC Icenowy Zheng <icenowy@aosc.io> - 2017-03-29 22:30 +0200
  [PATCH v3 11/11] [DO NOT MERGE] ARM: dts: sun8i: enable LCD panel of Lichee Pi Zero Icenowy Zheng <icenowy@aosc.io> - 2017-03-29 22:40 +0200
  [PATCH v3 02/11] clk: sunxi-ng: add support for DE2 CCU Icenowy Zheng <icenowy@aosc.io> - 2017-03-29 23:10 +0200
  [PATCH v3 03/11] dt-bindings: add bindings for DE2 on V3s SoC Icenowy Zheng <icenowy@aosc.io> - 2017-03-29 23:30 +0200
    Re: [PATCH v3 03/11] dt-bindings: add bindings for DE2 on V3s SoC Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-04-03 10:10 +0200
  [PATCH v3 04/11] drm/sun4i: abstract the layer type Icenowy Zheng <icenowy@aosc.io> - 2017-03-29 23:40 +0200
    Re: [PATCH v3 04/11] drm/sun4i: abstract the layer type Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-04-03 10:20 +0200
      Re: [PATCH v3 04/11] drm/sun4i: abstract the layer type Chen-Yu Tsai <wens@csie.org> - 2017-04-03 13:00 +0200
    Re: [PATCH v3 04/11] drm/sun4i: abstract the layer type Sean Paul <seanpaul@chromium.org> - 2017-04-04 21:30 +0200
      Re: [linux-sunxi] Re: [PATCH v3 04/11] drm/sun4i: abstract the layer type Chen-Yu Tsai <wens@csie.org> - 2017-04-05 04:30 +0200
        Re: [linux-sunxi] Re: [PATCH v3 04/11] drm/sun4i: abstract the layer  type icenowy@aosc.io - 2017-04-05 19:20 +0200
  [PATCH v3 06/11] drm/sun4i: add support for Allwinner DE2 mixers Icenowy Zheng <icenowy@aosc.io> - 2017-03-29 23:50 +0200
    Re: [linux-sunxi] [PATCH v3 06/11] drm/sun4i: add support for Allwinner DE2 mixers Jernej Škrabec <jernej.skrabec@siol.net> - 2017-03-30 00:40 +0200
  [PATCH v3 05/11] drm/sun4i: abstract a mixer type Icenowy Zheng <icenowy@aosc.io> - 2017-03-29 23:50 +0200
    Re: [PATCH v3 05/11] drm/sun4i: abstract a mixer type Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-04-03 10:30 +0200

csiph-web