Thomas Zimmermann
2021-Oct-22 13:28 UTC
[PATCH 1/9] drm/format-helper: Export drm_fb_clip_offset()
Provide a function that computes the offset into a blit destination buffer. This will allow to move destination-buffer clipping into the format-helper callers. Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> --- drivers/gpu/drm/drm_format_helper.c | 10 ++++++++-- include/drm/drm_format_helper.h | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c index 69fde60e36b3..28e9d0d89270 100644 --- a/drivers/gpu/drm/drm_format_helper.c +++ b/drivers/gpu/drm/drm_format_helper.c @@ -17,12 +17,18 @@ #include <drm/drm_fourcc.h> #include <drm/drm_rect.h> -static unsigned int clip_offset(struct drm_rect *clip, - unsigned int pitch, unsigned int cpp) +static unsigned int clip_offset(const struct drm_rect *clip, unsigned int pitch, unsigned int cpp) { return clip->y1 * pitch + clip->x1 * cpp; } +unsigned long drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format, + const struct drm_rect *clip) +{ + return clip_offset(clip, pitch, format->cpp[0]); +} +EXPORT_SYMBOL(drm_fb_clip_offset); + /** * drm_fb_memcpy - Copy clip buffer * @dst: Destination buffer diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h index e86925cf07b9..90b9bd9ecb83 100644 --- a/include/drm/drm_format_helper.h +++ b/include/drm/drm_format_helper.h @@ -6,9 +6,13 @@ #ifndef __LINUX_DRM_FORMAT_HELPER_H #define __LINUX_DRM_FORMAT_HELPER_H +struct drm_format_info; struct drm_framebuffer; struct drm_rect; +unsigned long drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format, + const struct drm_rect *clip); + void drm_fb_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb, struct drm_rect *clip); void drm_fb_memcpy_dstclip(void __iomem *dst, unsigned int dst_pitch, void *vaddr, -- 2.33.0
Sam Ravnborg
2021-Oct-23 07:49 UTC
[PATCH 1/9] drm/format-helper: Export drm_fb_clip_offset()
Hi Thomas, On Fri, Oct 22, 2021 at 03:28:21PM +0200, Thomas Zimmermann wrote:> Provide a function that computes the offset into a blit destination > buffer. This will allow to move destination-buffer clipping into the > format-helper callers. > > Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> > --- > drivers/gpu/drm/drm_format_helper.c | 10 ++++++++-- > include/drm/drm_format_helper.h | 4 ++++ > 2 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c > index 69fde60e36b3..28e9d0d89270 100644 > --- a/drivers/gpu/drm/drm_format_helper.c > +++ b/drivers/gpu/drm/drm_format_helper.c > @@ -17,12 +17,18 @@ > #include <drm/drm_fourcc.h> > #include <drm/drm_rect.h> > > -static unsigned int clip_offset(struct drm_rect *clip, > - unsigned int pitch, unsigned int cpp) > +static unsigned int clip_offset(const struct drm_rect *clip, unsigned int pitch, unsigned int cpp) > { > return clip->y1 * pitch + clip->x1 * cpp; > } > > +unsigned long drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format, > + const struct drm_rect *clip) > +{ > + return clip_offset(clip, pitch, format->cpp[0]); > +} > +EXPORT_SYMBOL(drm_fb_clip_offset);Exported functions are expected to have kernel-doc documentation. Just copy more or less from the changelog I think. Anywhere else (I looked in struct drm_framebuffer) we only need unsigned int for offsets and width/length - so I cannot see why we do an unsigned int => unsigned long conversion here. Sam> + > /** > * drm_fb_memcpy - Copy clip buffer > * @dst: Destination buffer > diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h > index e86925cf07b9..90b9bd9ecb83 100644 > --- a/include/drm/drm_format_helper.h > +++ b/include/drm/drm_format_helper.h > @@ -6,9 +6,13 @@ > #ifndef __LINUX_DRM_FORMAT_HELPER_H > #define __LINUX_DRM_FORMAT_HELPER_H > > +struct drm_format_info; > struct drm_framebuffer; > struct drm_rect; > > +unsigned long drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format, > + const struct drm_rect *clip); > + > void drm_fb_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb, > struct drm_rect *clip); > void drm_fb_memcpy_dstclip(void __iomem *dst, unsigned int dst_pitch, void *vaddr, > -- > 2.33.0
Noralf Trønnes
2021-Oct-24 08:25 UTC
[PATCH 1/9] drm/format-helper: Export drm_fb_clip_offset()
Den 22.10.2021 15.28, skrev Thomas Zimmermann:> Provide a function that computes the offset into a blit destination > buffer. This will allow to move destination-buffer clipping into the > format-helper callers. > > Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> > --- > drivers/gpu/drm/drm_format_helper.c | 10 ++++++++-- > include/drm/drm_format_helper.h | 4 ++++ > 2 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c > index 69fde60e36b3..28e9d0d89270 100644 > --- a/drivers/gpu/drm/drm_format_helper.c > +++ b/drivers/gpu/drm/drm_format_helper.c > @@ -17,12 +17,18 @@ > #include <drm/drm_fourcc.h> > #include <drm/drm_rect.h> > > -static unsigned int clip_offset(struct drm_rect *clip, > - unsigned int pitch, unsigned int cpp) > +static unsigned int clip_offset(const struct drm_rect *clip, unsigned int pitch, unsigned int cpp) > { > return clip->y1 * pitch + clip->x1 * cpp; > } > > +unsigned long drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format,Like Sam I wonder about the unsigned long here. Noralf.> + const struct drm_rect *clip) > +{ > + return clip_offset(clip, pitch, format->cpp[0]); > +} > +EXPORT_SYMBOL(drm_fb_clip_offset); > +
Thomas Zimmermann
2021-Nov-01 08:43 UTC
[PATCH 1/9] drm/format-helper: Export drm_fb_clip_offset()
Hi Am 23.10.21 um 09:49 schrieb Sam Ravnborg:> Hi Thomas, > > On Fri, Oct 22, 2021 at 03:28:21PM +0200, Thomas Zimmermann wrote: >> Provide a function that computes the offset into a blit destination >> buffer. This will allow to move destination-buffer clipping into the >> format-helper callers. >> >> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> >> --- >> drivers/gpu/drm/drm_format_helper.c | 10 ++++++++-- >> include/drm/drm_format_helper.h | 4 ++++ >> 2 files changed, 12 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c >> index 69fde60e36b3..28e9d0d89270 100644 >> --- a/drivers/gpu/drm/drm_format_helper.c >> +++ b/drivers/gpu/drm/drm_format_helper.c >> @@ -17,12 +17,18 @@ >> #include <drm/drm_fourcc.h> >> #include <drm/drm_rect.h> >> >> -static unsigned int clip_offset(struct drm_rect *clip, >> - unsigned int pitch, unsigned int cpp) >> +static unsigned int clip_offset(const struct drm_rect *clip, unsigned int pitch, unsigned int cpp) >> { >> return clip->y1 * pitch + clip->x1 * cpp; >> } >> >> +unsigned long drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format, >> + const struct drm_rect *clip) >> +{ >> + return clip_offset(clip, pitch, format->cpp[0]); >> +} >> +EXPORT_SYMBOL(drm_fb_clip_offset); > > Exported functions are expected to have kernel-doc documentation. > Just copy more or less from the changelog I think.That's an oversight. Sorry.> > Anywhere else (I looked in struct drm_framebuffer) we only need unsigned > int for offsets and width/length - so I cannot see why we do an unsigned > int => unsigned long conversion here.On ancient platforms, int was 16 bit wide. So for values that are array indices or buffer indices, I naturally use long, which is 32-bit at least. Never mind, it's not relevant any longer. I'll convert this code to unsigned int. Best regards Thomas> > Sam > >> + >> /** >> * drm_fb_memcpy - Copy clip buffer >> * @dst: Destination buffer >> diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h >> index e86925cf07b9..90b9bd9ecb83 100644 >> --- a/include/drm/drm_format_helper.h >> +++ b/include/drm/drm_format_helper.h >> @@ -6,9 +6,13 @@ >> #ifndef __LINUX_DRM_FORMAT_HELPER_H >> #define __LINUX_DRM_FORMAT_HELPER_H >> >> +struct drm_format_info; >> struct drm_framebuffer; >> struct drm_rect; >> >> +unsigned long drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format, >> + const struct drm_rect *clip); >> + >> void drm_fb_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb, >> struct drm_rect *clip); >> void drm_fb_memcpy_dstclip(void __iomem *dst, unsigned int dst_pitch, void *vaddr, >> -- >> 2.33.0-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 N?rnberg, Germany (HRB 36809, AG N?rnberg) Gesch?ftsf?hrer: Ivo Totev -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 840 bytes Desc: OpenPGP digital signature URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20211101/cf57f7cc/attachment-0001.sig>