diff mbox

Add drmModeAddFB2WithModifiers() which takes format modifiers

Message ID 1473804475-53897-1-git-send-email-hoegsberg@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Kristian Høgsberg Sept. 13, 2016, 10:07 p.m. UTC
The only current user of this open codes the ioctl. Let's add an entry
point for this to libdrm.

Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
---
 xf86drmMode.c | 21 +++++++++++++++++----
 xf86drmMode.h |  7 +++++++
 2 files changed, 24 insertions(+), 4 deletions(-)

Comments

Rob Clark Sept. 13, 2016, 10:59 p.m. UTC | #1
On Tue, Sep 13, 2016 at 6:07 PM, Kristian H. Kristensen
<hoegsberg@gmail.com> wrote:
> The only current user of this open codes the ioctl. Let's add an entry
> point for this to libdrm.
>
> Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
> ---
>  xf86drmMode.c | 21 +++++++++++++++++----
>  xf86drmMode.h |  7 +++++++
>  2 files changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/xf86drmMode.c b/xf86drmMode.c
> index f7b5948..2907c5c 100644
> --- a/xf86drmMode.c
> +++ b/xf86drmMode.c
> @@ -270,10 +270,10 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
>         return 0;
>  }
>
> -int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
> -                 uint32_t pixel_format, uint32_t bo_handles[4],
> -                 uint32_t pitches[4], uint32_t offsets[4],
> -                 uint32_t *buf_id, uint32_t flags)
> +int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
> +                               uint32_t pixel_format, uint32_t bo_handles[4],
> +                               uint32_t pitches[4], uint32_t offsets[4],
> +                               uint64_t modifier[4], uint32_t *buf_id, uint32_t flags)
>  {
>         struct drm_mode_fb_cmd2 f;
>         int ret;
> @@ -286,6 +286,8 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
>         memcpy(f.handles, bo_handles, 4 * sizeof(bo_handles[0]));
>         memcpy(f.pitches, pitches, 4 * sizeof(pitches[0]));
>         memcpy(f.offsets, offsets, 4 * sizeof(offsets[0]));
> +        if (modifier)
> +               memcpy(f.modifier, modifier, 4 * sizeof(modifier[0]));

I can't quite tell if it is my email client or not, but the
whitespace/indentation here and below in drmModeAddFB2() looks funny..
other than that (and with that potentially fixed if needed), lgtm

Reviewed-by: Rob Clark <robdclark@gmail.com>

>         if ((ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_ADDFB2, &f)))
>                 return ret;
> @@ -294,6 +296,17 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
>         return 0;
>  }
>
> +int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
> +                  uint32_t pixel_format, uint32_t bo_handles[4],
> +                  uint32_t pitches[4], uint32_t offsets[4],
> +                  uint32_t *buf_id, uint32_t flags)
> +{
> +  return drmModeAddFB2WithModifiers(fd, width, height,
> +                                    pixel_format, bo_handles,
> +                                    pitches, offsets, NULL,
> +                                    buf_id, flags);
> +}
> +
>  int drmModeRmFB(int fd, uint32_t bufferId)
>  {
>         return DRM_IOCTL(fd, DRM_IOCTL_MODE_RMFB, &bufferId);
> diff --git a/xf86drmMode.h b/xf86drmMode.h
> index 4de7bbb..02190ea 100644
> --- a/xf86drmMode.h
> +++ b/xf86drmMode.h
> @@ -369,6 +369,13 @@ extern int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
>                          uint32_t pixel_format, uint32_t bo_handles[4],
>                          uint32_t pitches[4], uint32_t offsets[4],
>                          uint32_t *buf_id, uint32_t flags);
> +
> +/* ...with format modifiers */
> +int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
> +                               uint32_t pixel_format, uint32_t bo_handles[4],
> +                               uint32_t pitches[4], uint32_t offsets[4],
> +                               uint64_t modifier[4], uint32_t *buf_id, uint32_t flags);
> +
>  /**
>   * Destroies the given framebuffer.
>   */
> --
> 2.8.0.rc3.226.g39d4020
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Kristian Høgsberg Sept. 14, 2016, 4:16 p.m. UTC | #2
On Tue, Sep 13, 2016 at 3:59 PM, Rob Clark <robdclark@gmail.com> wrote:
> On Tue, Sep 13, 2016 at 6:07 PM, Kristian H. Kristensen
> <hoegsberg@gmail.com> wrote:
>> The only current user of this open codes the ioctl. Let's add an entry
>> point for this to libdrm.
>>
>> Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
>> ---
>>  xf86drmMode.c | 21 +++++++++++++++++----
>>  xf86drmMode.h |  7 +++++++
>>  2 files changed, 24 insertions(+), 4 deletions(-)
>>
>> diff --git a/xf86drmMode.c b/xf86drmMode.c
>> index f7b5948..2907c5c 100644
>> --- a/xf86drmMode.c
>> +++ b/xf86drmMode.c
>> @@ -270,10 +270,10 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
>>         return 0;
>>  }
>>
>> -int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
>> -                 uint32_t pixel_format, uint32_t bo_handles[4],
>> -                 uint32_t pitches[4], uint32_t offsets[4],
>> -                 uint32_t *buf_id, uint32_t flags)
>> +int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
>> +                               uint32_t pixel_format, uint32_t bo_handles[4],
>> +                               uint32_t pitches[4], uint32_t offsets[4],
>> +                               uint64_t modifier[4], uint32_t *buf_id, uint32_t flags)
>>  {
>>         struct drm_mode_fb_cmd2 f;
>>         int ret;
>> @@ -286,6 +286,8 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
>>         memcpy(f.handles, bo_handles, 4 * sizeof(bo_handles[0]));
>>         memcpy(f.pitches, pitches, 4 * sizeof(pitches[0]));
>>         memcpy(f.offsets, offsets, 4 * sizeof(offsets[0]));
>> +        if (modifier)
>> +               memcpy(f.modifier, modifier, 4 * sizeof(modifier[0]));
>
> I can't quite tell if it is my email client or not, but the
> whitespace/indentation here and below in drmModeAddFB2() looks funny..
> other than that (and with that potentially fixed if needed), lgtm

Ah, yup, there's some broken whitespace there, will fix.

> Reviewed-by: Rob Clark <robdclark@gmail.com>

Thanks!

>
>>         if ((ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_ADDFB2, &f)))
>>                 return ret;
>> @@ -294,6 +296,17 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
>>         return 0;
>>  }
>>
>> +int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
>> +                  uint32_t pixel_format, uint32_t bo_handles[4],
>> +                  uint32_t pitches[4], uint32_t offsets[4],
>> +                  uint32_t *buf_id, uint32_t flags)
>> +{
>> +  return drmModeAddFB2WithModifiers(fd, width, height,
>> +                                    pixel_format, bo_handles,
>> +                                    pitches, offsets, NULL,
>> +                                    buf_id, flags);
>> +}
>> +
>>  int drmModeRmFB(int fd, uint32_t bufferId)
>>  {
>>         return DRM_IOCTL(fd, DRM_IOCTL_MODE_RMFB, &bufferId);
>> diff --git a/xf86drmMode.h b/xf86drmMode.h
>> index 4de7bbb..02190ea 100644
>> --- a/xf86drmMode.h
>> +++ b/xf86drmMode.h
>> @@ -369,6 +369,13 @@ extern int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
>>                          uint32_t pixel_format, uint32_t bo_handles[4],
>>                          uint32_t pitches[4], uint32_t offsets[4],
>>                          uint32_t *buf_id, uint32_t flags);
>> +
>> +/* ...with format modifiers */
>> +int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
>> +                               uint32_t pixel_format, uint32_t bo_handles[4],
>> +                               uint32_t pitches[4], uint32_t offsets[4],
>> +                               uint64_t modifier[4], uint32_t *buf_id, uint32_t flags);
>> +
>>  /**
>>   * Destroies the given framebuffer.
>>   */
>> --
>> 2.8.0.rc3.226.g39d4020
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Alexandre Courbot Sept. 20, 2016, 9:02 a.m. UTC | #3
On 09/14/2016 07:07 AM, Kristian H. Kristensen wrote:
> The only current user of this open codes the ioctl. Let's add an entry
> point for this to libdrm.

Tested-by: Alexandre Courbot <acourbot@nvidia.com>

Replaced one custom (staging) ioctl on Tegra with FB modifiers, noticed
this was missing!

> 
> Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
> ---
>  xf86drmMode.c | 21 +++++++++++++++++----
>  xf86drmMode.h |  7 +++++++
>  2 files changed, 24 insertions(+), 4 deletions(-)
> 
> diff --git a/xf86drmMode.c b/xf86drmMode.c
> index f7b5948..2907c5c 100644
> --- a/xf86drmMode.c
> +++ b/xf86drmMode.c
> @@ -270,10 +270,10 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
>  	return 0;
>  }
>  
> -int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
> -		  uint32_t pixel_format, uint32_t bo_handles[4],
> -		  uint32_t pitches[4], uint32_t offsets[4],
> -		  uint32_t *buf_id, uint32_t flags)
> +int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
> +                               uint32_t pixel_format, uint32_t bo_handles[4],
> +                               uint32_t pitches[4], uint32_t offsets[4],
> +                               uint64_t modifier[4], uint32_t *buf_id, uint32_t flags)
>  {
>  	struct drm_mode_fb_cmd2 f;
>  	int ret;
> @@ -286,6 +286,8 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
>  	memcpy(f.handles, bo_handles, 4 * sizeof(bo_handles[0]));
>  	memcpy(f.pitches, pitches, 4 * sizeof(pitches[0]));
>  	memcpy(f.offsets, offsets, 4 * sizeof(offsets[0]));
> +        if (modifier)
> +		memcpy(f.modifier, modifier, 4 * sizeof(modifier[0]));
>  
>  	if ((ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_ADDFB2, &f)))
>  		return ret;
> @@ -294,6 +296,17 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
>  	return 0;
>  }
>  
> +int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
> +                  uint32_t pixel_format, uint32_t bo_handles[4],
> +                  uint32_t pitches[4], uint32_t offsets[4],
> +                  uint32_t *buf_id, uint32_t flags)
> +{
> +  return drmModeAddFB2WithModifiers(fd, width, height,
> +                                    pixel_format, bo_handles,
> +                                    pitches, offsets, NULL,
> +                                    buf_id, flags);
> +}
> +
>  int drmModeRmFB(int fd, uint32_t bufferId)
>  {
>  	return DRM_IOCTL(fd, DRM_IOCTL_MODE_RMFB, &bufferId);
> diff --git a/xf86drmMode.h b/xf86drmMode.h
> index 4de7bbb..02190ea 100644
> --- a/xf86drmMode.h
> +++ b/xf86drmMode.h
> @@ -369,6 +369,13 @@ extern int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
>  			 uint32_t pixel_format, uint32_t bo_handles[4],
>  			 uint32_t pitches[4], uint32_t offsets[4],
>  			 uint32_t *buf_id, uint32_t flags);
> +
> +/* ...with format modifiers */
> +int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
> +                               uint32_t pixel_format, uint32_t bo_handles[4],
> +                               uint32_t pitches[4], uint32_t offsets[4],
> +                               uint64_t modifier[4], uint32_t *buf_id, uint32_t flags);
> +
>  /**
>   * Destroies the given framebuffer.
>   */
>
diff mbox

Patch

diff --git a/xf86drmMode.c b/xf86drmMode.c
index f7b5948..2907c5c 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -270,10 +270,10 @@  int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
 	return 0;
 }
 
-int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
-		  uint32_t pixel_format, uint32_t bo_handles[4],
-		  uint32_t pitches[4], uint32_t offsets[4],
-		  uint32_t *buf_id, uint32_t flags)
+int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
+                               uint32_t pixel_format, uint32_t bo_handles[4],
+                               uint32_t pitches[4], uint32_t offsets[4],
+                               uint64_t modifier[4], uint32_t *buf_id, uint32_t flags)
 {
 	struct drm_mode_fb_cmd2 f;
 	int ret;
@@ -286,6 +286,8 @@  int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
 	memcpy(f.handles, bo_handles, 4 * sizeof(bo_handles[0]));
 	memcpy(f.pitches, pitches, 4 * sizeof(pitches[0]));
 	memcpy(f.offsets, offsets, 4 * sizeof(offsets[0]));
+        if (modifier)
+		memcpy(f.modifier, modifier, 4 * sizeof(modifier[0]));
 
 	if ((ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_ADDFB2, &f)))
 		return ret;
@@ -294,6 +296,17 @@  int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
 	return 0;
 }
 
+int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
+                  uint32_t pixel_format, uint32_t bo_handles[4],
+                  uint32_t pitches[4], uint32_t offsets[4],
+                  uint32_t *buf_id, uint32_t flags)
+{
+  return drmModeAddFB2WithModifiers(fd, width, height,
+                                    pixel_format, bo_handles,
+                                    pitches, offsets, NULL,
+                                    buf_id, flags);
+}
+
 int drmModeRmFB(int fd, uint32_t bufferId)
 {
 	return DRM_IOCTL(fd, DRM_IOCTL_MODE_RMFB, &bufferId);
diff --git a/xf86drmMode.h b/xf86drmMode.h
index 4de7bbb..02190ea 100644
--- a/xf86drmMode.h
+++ b/xf86drmMode.h
@@ -369,6 +369,13 @@  extern int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
 			 uint32_t pixel_format, uint32_t bo_handles[4],
 			 uint32_t pitches[4], uint32_t offsets[4],
 			 uint32_t *buf_id, uint32_t flags);
+
+/* ...with format modifiers */
+int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
+                               uint32_t pixel_format, uint32_t bo_handles[4],
+                               uint32_t pitches[4], uint32_t offsets[4],
+                               uint64_t modifier[4], uint32_t *buf_id, uint32_t flags);
+
 /**
  * Destroies the given framebuffer.
  */