linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Daniel Stone <daniel@fooishbar.org>, Daniel Vetter <daniel@ffwll.ch>
Cc: linux-omap@vger.kernel.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Rob Clark <robdclark@gmail.com>
Subject: Re: [PATCH 09/21] drm/omap: handle mismatching color format and buffer width
Date: Mon, 2 Mar 2015 11:50:35 +0200	[thread overview]
Message-ID: <54F4326B.6040209@ti.com> (raw)
In-Reply-To: <CAPj87rP4675D9WY8eGUPCePcx7Oi+faYs5K4B_BGtyh1H4RmJA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3486 bytes --]

On 27/02/15 16:40, Daniel Stone wrote:
> Hi,
> 
> On 27 February 2015 at 13:01, Daniel Vetter <daniel@ffwll.ch> wrote:
>> On Thu, Feb 26, 2015 at 03:20:17PM +0200, Tomi Valkeinen wrote:
>>> omapdrm doesn't check if the width of the framebuffer and the color
> 
> s/width/pitch/
> 
>>> format's bits-per-pixel match.
> 
> s/match/are compatible/
> 
>>> For example, using a display with a width of 1280, and a buffer
>>> allocated with using 32 bits per pixel (i.e. 1280*4 = 5120 bytes), with
> 
> Might be clearer to say 'i.e. byte stride of ...', and also s/with using/for/.

Above you said pitch, here you say stride. They are the same thing, right?

>>> a 24 bits per pixel color format, leads to the following mismatch:
>>> 5120/3 = 1706.666... bytes. This causes bad colors and a tilt on the
> 
> s/bytes/pixels/
> 
>>> screen.
>>>
>>> Add a check into omapdrm to return an error if the user tries to use
>>> such a combination.
>>>
>>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
>>> ---
>>>  drivers/gpu/drm/omapdrm/omap_fb.c | 8 ++++++++
>>>  1 file changed, 8 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
>>> index 2975096abdf5..bf98580223d0 100644
>>> --- a/drivers/gpu/drm/omapdrm/omap_fb.c
>>> +++ b/drivers/gpu/drm/omapdrm/omap_fb.c
>>> @@ -463,6 +463,14 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
>>>                       goto fail;
>>>               }
>>>
>>> +             if (mode_cmd->width % format->planes[i].stride_bpp != 0) {
>>
>> width is in pixels. No idea what you're trying to check here, but this
>> probably isn't it.

Yep, I don't know what I was smoking when writing the patch...

> stride_bpp is very misnamed: it is the bits per pixel for that plane,
> and not stride at all. I think the check should in fact be be (pitch %

I don't know why Rob named it like that. "The bpp of the stride"? Shrug.

> format->planes[i].stride_bpp), which would achieve the desired result,
> i.e. that the stride can be expressed as an integer number of pixels.

Yes, that looks correct.

>> Also drm checks that things fit into the specified pitch (which is in
>> bytes), see the pichtes[i] < width * cpp check in framebuffer_check.
> 
> This isn't that check. At some stages, OMAP IIRC requires pitch to be
> specified in pixels rather than bytes, so this makes sure that's
> possible to express.

Right, that's what this patch was trying to achieve.

However... After thinking about this and going through some of the DISPC
code, I think that's not a strict requirement. We do calculate all the
configs using pixels as units, so at the moment the stride has to be an
integer number of pixels. But the hardware actually takes the row-inc
and pix-inc as bytes.

That said, the HW supports features like rotation and whatnot, and it
was not clear with a quick study if there are corner cases where the
hardware also requires the stride to be an integer number of pixels.
Also, the HW documentation only talks about pixels in this context, even
if the final value written to the registers is in bytes. I don't know if
that's just to make the documentation simpler, or if there's some
reasoning to only use pixel units.

So I think for the time being I'll just fix this patch, and look at the
possibility of allowing any stride size in the future.

Thanks for the review!

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2015-03-02  9:50 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26 13:20 [PATCH 00/21] drm/omap: misc fixes/improvements Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 01/21] drm/omap: fix encoder-crtc mapping Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 02/21] drm/omap: page_flip: return -EBUSY if flip pending Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 03/21] drm/omap: clear omap_obj->paddr in omap_gem_put_paddr() Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 04/21] drm/omap: add pin refcounting to omap_framebuffer Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 05/21] drm/omap: add a comment why locking is missing Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 06/21] drm/omap: check CRTC color format earlier Tomi Valkeinen
2015-02-27 12:07   ` Daniel Vetter
2015-03-02  9:55     ` Tomi Valkeinen
2015-03-04 23:41       ` Laurent Pinchart
2015-03-04 23:53     ` Laurent Pinchart
2015-02-26 13:20 ` [PATCH 07/21] drm/omap: fix operation without fbdev Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 08/21] drm/omap: fix error handling in omap_framebuffer_create() Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 09/21] drm/omap: handle mismatching color format and buffer width Tomi Valkeinen
2015-02-27 13:01   ` Daniel Vetter
2015-02-27 14:40     ` Daniel Stone
2015-02-27 15:47       ` Daniel Vetter
2015-03-02  9:50       ` Tomi Valkeinen [this message]
2015-03-02 10:22         ` Daniel Stone
2015-03-02 10:32           ` Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 10/21] drm/omap: fix TILER on OMAP5 Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 11/21] drm/omap: fix plane's channel selection Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 12/21] drm/omap: tiler: fix race condition with engine->async Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 13/21] drm/omap: remove dummy PM functions Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 14/21] drm/omap: stop connector polling during suspend Tomi Valkeinen
2015-02-26 13:57   ` Grygorii.Strashko@linaro.org
2015-03-02 11:03     ` Tomi Valkeinen
2015-03-02 18:35       ` Grygorii Strashko
2015-02-26 13:20 ` [PATCH 15/21] drm/omap: use DRM_ERROR_RATELIMITED() for error irqs Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 16/21] drm/omap: fix race with error_irq Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 17/21] drm/omap: only ignore DIGIT SYNC LOST for TV output Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 18/21] drm/omap: do not use BUG_ON(!spin_is_locked(x)) Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 19/21] drm/omap: fix race condition with dev->obj_list Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 20/21] drm/omap: fix race conditon in DMM Tomi Valkeinen
2015-02-26 13:20 ` [PATCH 21/21] drm/omap: keep ref to old_fb Tomi Valkeinen

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=54F4326B.6040209@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=daniel@ffwll.ch \
    --cc=daniel@fooishbar.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=robdclark@gmail.com \
    /path/to/YOUR_REPLY

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

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