2b815787689f8ee6924ddc749ab0673f332b9596
[openwrt/staging/blogic.git] /
1 From 4b1b99ebbada744ef72af56b022492609feb9bba Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Thu, 3 Nov 2016 18:53:10 -0700
4 Subject: [PATCH] drm/vc4: Add support for rendering with ETC1 textures.
5
6 The validation for it ends up being quite simple, but I hadn't got
7 around to it before merging the driver. For backwards compatibility,
8 we also need to add a flag so that the userspace GL driver can easily
9 tell if the kernel will allow ETC1 textures (on an old kernel, it will
10 continue to convert to RGBA8)
11
12 Signed-off-by: Eric Anholt <eric@anholt.net>
13 (cherry picked from commit 7154d76fedf549607afbc0d13db9aaf02da5cebf)
14 ---
15 drivers/gpu/drm/vc4/vc4_drv.c | 1 +
16 drivers/gpu/drm/vc4/vc4_validate.c | 7 +++++++
17 include/uapi/drm/vc4_drm.h | 1 +
18 3 files changed, 9 insertions(+)
19
20 --- a/drivers/gpu/drm/vc4/vc4_drv.c
21 +++ b/drivers/gpu/drm/vc4/vc4_drv.c
22 @@ -78,6 +78,7 @@ static int vc4_get_param_ioctl(struct dr
23 pm_runtime_put(&vc4->v3d->pdev->dev);
24 break;
25 case DRM_VC4_PARAM_SUPPORTS_BRANCHES:
26 + case DRM_VC4_PARAM_SUPPORTS_ETC1:
27 args->value = true;
28 break;
29 default:
30 --- a/drivers/gpu/drm/vc4/vc4_validate.c
31 +++ b/drivers/gpu/drm/vc4/vc4_validate.c
32 @@ -644,6 +644,13 @@ reloc_tex(struct vc4_exec_info *exec,
33 cpp = 1;
34 break;
35 case VC4_TEXTURE_TYPE_ETC1:
36 + /* ETC1 is arranged as 64-bit blocks, where each block is 4x4
37 + * pixels.
38 + */
39 + cpp = 8;
40 + width = (width + 3) >> 2;
41 + height = (height + 3) >> 2;
42 + break;
43 case VC4_TEXTURE_TYPE_BW1:
44 case VC4_TEXTURE_TYPE_A4:
45 case VC4_TEXTURE_TYPE_A1:
46 --- a/include/uapi/drm/vc4_drm.h
47 +++ b/include/uapi/drm/vc4_drm.h
48 @@ -286,6 +286,7 @@ struct drm_vc4_get_hang_state {
49 #define DRM_VC4_PARAM_V3D_IDENT1 1
50 #define DRM_VC4_PARAM_V3D_IDENT2 2
51 #define DRM_VC4_PARAM_SUPPORTS_BRANCHES 3
52 +#define DRM_VC4_PARAM_SUPPORTS_ETC1 4
53
54 struct drm_vc4_get_param {
55 __u32 param;