Re: [PATCH v1 1/2] drm/stm: ltdc: add non-alpha color formats

2018-02-08 Thread Philippe CORNU
Hi Benjamin,
and many thanks for having applied the 2 patches.
Philippe :-)

On 02/08/2018 10:40 AM, Benjamin Gaignard wrote:
> 2018-02-06 10:12 GMT+01:00 Yannick FERTRE :
>> Reviewed-by: Yannick Fertré 
>>
>>
>> On 02/01/2018 11:42 AM, Philippe Cornu wrote:
>>> ltdc supports natively some color formats with alpha (like
>>> ARGB, ARGB1555, ARGB...). Related non-alpha formats are
>>> supported too (ARGB->XRGB, ARGB->XRGB...) by
>>> adjusting ltdc blending factors.
>>>
>>> Note: Wayland/Weston requests by default the non-alpha XRGB
>>> color format.
>>>
>>> Signed-off-by: Philippe Cornu 
> 
> Applied on drm-misc-next
> 
> Benjamin
>>> ---
>>>drivers/gpu/drm/stm/ltdc.c | 33 +++--
>>>1 file changed, 31 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
>>> index 90b3de516c91..f6f26fc0ae9e 100644
>>> --- a/drivers/gpu/drm/stm/ltdc.c
>>> +++ b/drivers/gpu/drm/stm/ltdc.c
>>> @@ -328,6 +328,26 @@ static inline u32 to_drm_pixelformat(enum ltdc_pix_fmt 
>>> pf)
>>>}
>>>}
>>>
>>> +static inline u32 get_pixelformat_without_alpha(u32 drm)
>>> +{
>>> + switch (drm) {
>>> + case DRM_FORMAT_ARGB:
>>> + return DRM_FORMAT_XRGB;
>>> + case DRM_FORMAT_RGBA:
>>> + return DRM_FORMAT_RGBX;
>>> + case DRM_FORMAT_ARGB1555:
>>> + return DRM_FORMAT_XRGB1555;
>>> + case DRM_FORMAT_RGBA5551:
>>> + return DRM_FORMAT_RGBX5551;
>>> + case DRM_FORMAT_ARGB:
>>> + return DRM_FORMAT_XRGB;
>>> + case DRM_FORMAT_RGBA:
>>> + return DRM_FORMAT_RGBX;
>>> + default:
>>> + return 0;
>>> + }
>>> +}
>>> +
>>>static irqreturn_t ltdc_irq_thread(int irq, void *arg)
>>>{
>>>struct drm_device *ddev = arg;
>>> @@ -680,6 +700,9 @@ static void ltdc_plane_atomic_update(struct drm_plane 
>>> *plane,
>>>
>>>/* Specifies the blending factors */
>>>val = BF1_PAXCA | BF2_1PAXCA;
>>> + if (!fb->format->has_alpha)
>>> + val = BF1_CA | BF2_1CA;
>>> +
>>>reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs,
>>>LXBFCR_BF2 | LXBFCR_BF1, val);
>>>
>>> @@ -747,8 +770,8 @@ static struct drm_plane *ltdc_plane_create(struct 
>>> drm_device *ddev,
>>>struct device *dev = ddev->dev;
>>>struct drm_plane *plane;
>>>unsigned int i, nb_fmt = 0;
>>> - u32 formats[NB_PF];
>>> - u32 drm_fmt;
>>> + u32 formats[NB_PF * 2];
>>> + u32 drm_fmt, drm_fmt_no_alpha;
>>>int ret;
>>>
>>>/* Get supported pixel formats */
>>> @@ -757,6 +780,12 @@ static struct drm_plane *ltdc_plane_create(struct 
>>> drm_device *ddev,
>>>if (!drm_fmt)
>>>continue;
>>>formats[nb_fmt++] = drm_fmt;
>>> +
>>> + /* Add the no-alpha related format if any & supported */
>>> + drm_fmt_no_alpha = get_pixelformat_without_alpha(drm_fmt);
>>> + if (!drm_fmt_no_alpha)
>>> + continue;
>>> + formats[nb_fmt++] = drm_fmt_no_alpha;
>>>}
>>>
>>>plane = devm_kzalloc(dev, sizeof(*plane), GFP_KERNEL);
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 

Re: [PATCH v1 1/2] drm/stm: ltdc: add non-alpha color formats

2018-02-08 Thread Benjamin Gaignard
2018-02-06 10:12 GMT+01:00 Yannick FERTRE :
> Reviewed-by: Yannick Fertré 
>
>
> On 02/01/2018 11:42 AM, Philippe Cornu wrote:
>> ltdc supports natively some color formats with alpha (like
>> ARGB, ARGB1555, ARGB...). Related non-alpha formats are
>> supported too (ARGB->XRGB, ARGB->XRGB...) by
>> adjusting ltdc blending factors.
>>
>> Note: Wayland/Weston requests by default the non-alpha XRGB
>> color format.
>>
>> Signed-off-by: Philippe Cornu 

Applied on drm-misc-next

Benjamin
>> ---
>>   drivers/gpu/drm/stm/ltdc.c | 33 +++--
>>   1 file changed, 31 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
>> index 90b3de516c91..f6f26fc0ae9e 100644
>> --- a/drivers/gpu/drm/stm/ltdc.c
>> +++ b/drivers/gpu/drm/stm/ltdc.c
>> @@ -328,6 +328,26 @@ static inline u32 to_drm_pixelformat(enum ltdc_pix_fmt 
>> pf)
>>   }
>>   }
>>
>> +static inline u32 get_pixelformat_without_alpha(u32 drm)
>> +{
>> + switch (drm) {
>> + case DRM_FORMAT_ARGB:
>> + return DRM_FORMAT_XRGB;
>> + case DRM_FORMAT_RGBA:
>> + return DRM_FORMAT_RGBX;
>> + case DRM_FORMAT_ARGB1555:
>> + return DRM_FORMAT_XRGB1555;
>> + case DRM_FORMAT_RGBA5551:
>> + return DRM_FORMAT_RGBX5551;
>> + case DRM_FORMAT_ARGB:
>> + return DRM_FORMAT_XRGB;
>> + case DRM_FORMAT_RGBA:
>> + return DRM_FORMAT_RGBX;
>> + default:
>> + return 0;
>> + }
>> +}
>> +
>>   static irqreturn_t ltdc_irq_thread(int irq, void *arg)
>>   {
>>   struct drm_device *ddev = arg;
>> @@ -680,6 +700,9 @@ static void ltdc_plane_atomic_update(struct drm_plane 
>> *plane,
>>
>>   /* Specifies the blending factors */
>>   val = BF1_PAXCA | BF2_1PAXCA;
>> + if (!fb->format->has_alpha)
>> + val = BF1_CA | BF2_1CA;
>> +
>>   reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs,
>>   LXBFCR_BF2 | LXBFCR_BF1, val);
>>
>> @@ -747,8 +770,8 @@ static struct drm_plane *ltdc_plane_create(struct 
>> drm_device *ddev,
>>   struct device *dev = ddev->dev;
>>   struct drm_plane *plane;
>>   unsigned int i, nb_fmt = 0;
>> - u32 formats[NB_PF];
>> - u32 drm_fmt;
>> + u32 formats[NB_PF * 2];
>> + u32 drm_fmt, drm_fmt_no_alpha;
>>   int ret;
>>
>>   /* Get supported pixel formats */
>> @@ -757,6 +780,12 @@ static struct drm_plane *ltdc_plane_create(struct 
>> drm_device *ddev,
>>   if (!drm_fmt)
>>   continue;
>>   formats[nb_fmt++] = drm_fmt;
>> +
>> + /* Add the no-alpha related format if any & supported */
>> + drm_fmt_no_alpha = get_pixelformat_without_alpha(drm_fmt);
>> + if (!drm_fmt_no_alpha)
>> + continue;
>> + formats[nb_fmt++] = drm_fmt_no_alpha;
>>   }
>>
>>   plane = devm_kzalloc(dev, sizeof(*plane), GFP_KERNEL);


Re: [PATCH v1 1/2] drm/stm: ltdc: add non-alpha color formats

2018-02-06 Thread Yannick FERTRE
Reviewed-by: Yannick Fertré 


On 02/01/2018 11:42 AM, Philippe Cornu wrote:
> ltdc supports natively some color formats with alpha (like
> ARGB, ARGB1555, ARGB...). Related non-alpha formats are
> supported too (ARGB->XRGB, ARGB->XRGB...) by
> adjusting ltdc blending factors.
>
> Note: Wayland/Weston requests by default the non-alpha XRGB
> color format.
>
> Signed-off-by: Philippe Cornu 
> ---
>   drivers/gpu/drm/stm/ltdc.c | 33 +++--
>   1 file changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index 90b3de516c91..f6f26fc0ae9e 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -328,6 +328,26 @@ static inline u32 to_drm_pixelformat(enum ltdc_pix_fmt 
> pf)
>   }
>   }
>   
> +static inline u32 get_pixelformat_without_alpha(u32 drm)
> +{
> + switch (drm) {
> + case DRM_FORMAT_ARGB:
> + return DRM_FORMAT_XRGB;
> + case DRM_FORMAT_RGBA:
> + return DRM_FORMAT_RGBX;
> + case DRM_FORMAT_ARGB1555:
> + return DRM_FORMAT_XRGB1555;
> + case DRM_FORMAT_RGBA5551:
> + return DRM_FORMAT_RGBX5551;
> + case DRM_FORMAT_ARGB:
> + return DRM_FORMAT_XRGB;
> + case DRM_FORMAT_RGBA:
> + return DRM_FORMAT_RGBX;
> + default:
> + return 0;
> + }
> +}
> +
>   static irqreturn_t ltdc_irq_thread(int irq, void *arg)
>   {
>   struct drm_device *ddev = arg;
> @@ -680,6 +700,9 @@ static void ltdc_plane_atomic_update(struct drm_plane 
> *plane,
>   
>   /* Specifies the blending factors */
>   val = BF1_PAXCA | BF2_1PAXCA;
> + if (!fb->format->has_alpha)
> + val = BF1_CA | BF2_1CA;
> +
>   reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs,
>   LXBFCR_BF2 | LXBFCR_BF1, val);
>   
> @@ -747,8 +770,8 @@ static struct drm_plane *ltdc_plane_create(struct 
> drm_device *ddev,
>   struct device *dev = ddev->dev;
>   struct drm_plane *plane;
>   unsigned int i, nb_fmt = 0;
> - u32 formats[NB_PF];
> - u32 drm_fmt;
> + u32 formats[NB_PF * 2];
> + u32 drm_fmt, drm_fmt_no_alpha;
>   int ret;
>   
>   /* Get supported pixel formats */
> @@ -757,6 +780,12 @@ static struct drm_plane *ltdc_plane_create(struct 
> drm_device *ddev,
>   if (!drm_fmt)
>   continue;
>   formats[nb_fmt++] = drm_fmt;
> +
> + /* Add the no-alpha related format if any & supported */
> + drm_fmt_no_alpha = get_pixelformat_without_alpha(drm_fmt);
> + if (!drm_fmt_no_alpha)
> + continue;
> + formats[nb_fmt++] = drm_fmt_no_alpha;
>   }
>   
>   plane = devm_kzalloc(dev, sizeof(*plane), GFP_KERNEL);


Re: [PATCH v1 1/2] drm/stm: ltdc: add non-alpha color formats

2018-02-05 Thread kbuild test robot
Hi Philippe,

I love your patch! Yet something to improve:

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

url:
https://github.com/0day-ci/linux/commits/Philippe-Cornu/drm-stm-ltdc-add-non-alpha-color-formats/20180201-211736
base:   git://people.freedesktop.org/~airlied/linux.git drm-next
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/gpu//drm/stm/ltdc.c: In function 'ltdc_plane_atomic_update':
>> drivers/gpu//drm/stm/ltdc.c:661:17: error: 'const struct drm_format_info' 
>> has no member named 'has_alpha'
 if (!fb->format->has_alpha)
^~

vim +661 drivers/gpu//drm/stm/ltdc.c

   587  
   588  static void ltdc_plane_atomic_update(struct drm_plane *plane,
   589   struct drm_plane_state *oldstate)
   590  {
   591  struct ltdc_device *ldev = plane_to_ltdc(plane);
   592  struct drm_plane_state *state = plane->state;
   593  struct drm_framebuffer *fb = state->fb;
   594  u32 lofs = plane->index * LAY_OFS;
   595  u32 x0 = state->crtc_x;
   596  u32 x1 = state->crtc_x + state->crtc_w - 1;
   597  u32 y0 = state->crtc_y;
   598  u32 y1 = state->crtc_y + state->crtc_h - 1;
   599  u32 src_x, src_y, src_w, src_h;
   600  u32 val, pitch_in_bytes, line_length, paddr, ahbp, avbp, bpcr;
   601  enum ltdc_pix_fmt pf;
   602  
   603  if (!state->crtc || !fb) {
   604  DRM_DEBUG_DRIVER("fb or crtc NULL");
   605  return;
   606  }
   607  
   608  /* convert src_ from 16:16 format */
   609  src_x = state->src_x >> 16;
   610  src_y = state->src_y >> 16;
   611  src_w = state->src_w >> 16;
   612  src_h = state->src_h >> 16;
   613  
   614  DRM_DEBUG_DRIVER("plane:%d fb:%d (%dx%d)@(%d,%d) -> 
(%dx%d)@(%d,%d)\n",
   615   plane->base.id, fb->base.id,
   616   src_w, src_h, src_x, src_y,
   617   state->crtc_w, state->crtc_h,
   618   state->crtc_x, state->crtc_y);
   619  
   620  bpcr = reg_read(ldev->regs, LTDC_BPCR);
   621  ahbp = (bpcr & BPCR_AHBP) >> 16;
   622  avbp = bpcr & BPCR_AVBP;
   623  
   624  /* Configures the horizontal start and stop position */
   625  val = ((x1 + 1 + ahbp) << 16) + (x0 + 1 + ahbp);
   626  reg_update_bits(ldev->regs, LTDC_L1WHPCR + lofs,
   627  LXWHPCR_WHSTPOS | LXWHPCR_WHSPPOS, val);
   628  
   629  /* Configures the vertical start and stop position */
   630  val = ((y1 + 1 + avbp) << 16) + (y0 + 1 + avbp);
   631  reg_update_bits(ldev->regs, LTDC_L1WVPCR + lofs,
   632  LXWVPCR_WVSTPOS | LXWVPCR_WVSPPOS, val);
   633  
   634  /* Specifies the pixel format */
   635  pf = to_ltdc_pixelformat(fb->format->format);
   636  for (val = 0; val < NB_PF; val++)
   637  if (ldev->caps.pix_fmt_hw[val] == pf)
   638  break;
   639  
   640  if (val == NB_PF) {
   641  DRM_ERROR("Pixel format %.4s not supported\n",
   642(char *)&fb->format->format);
   643  val = 0;/* set by default ARGB 32 bits */
   644  }
   645  reg_update_bits(ldev->regs, LTDC_L1PFCR + lofs, LXPFCR_PF, val);
   646  
   647  /* Configures the color frame buffer pitch in bytes & line 
length */
   648  pitch_in_bytes = fb->pitches[0];
   649  line_length = drm_format_plane_cpp(fb->format->format, 0) *
   650(x1 - x0 + 1) + (ldev->caps.bus_width >> 3) - 1;
   651  val = ((pitch_in_bytes << 16) | line_length);
   652  reg_update_bits(ldev->regs, LTDC_L1CFBLR + lofs,
   653  LXCFBLR_CFBLL | LXCFBLR_CFBP, val);
   654  
   655  /* Specifies the constant alpha value */
   656  val = CONSTA_MAX;
   657  reg_update_bits(ldev->regs, LTDC_L1CACR + lofs, LXCACR_CONSTA, 
val);
   658  
   659  /* Specifies the blending factors */
   660  val = BF1_PAXCA | BF2_1PAXCA;
 > 661  if (!fb->format->has_alpha)
   662  val = BF1_CA | BF2_1CA;
   663  
   664  reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs,
   665  LXBFCR_BF2 | LXBFCR_BF1, val);
   666  
   667  /