summaryrefslogtreecommitdiff
path: root/src/sna
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2018-05-29 21:33:12 +0300
committerChris Wilson <chris@chris-wilson.co.uk>2018-05-31 20:35:38 +0100
commit9c281c62dd8cd40913fd21ec5857bb55624fed8e (patch)
tree159fbb087a16e781ebf5a922325cf8b8d24949a4 /src/sna
parentd2a21702bde1d368177b5ead977b1fa9e078f25e (diff)
sna/video/sprite: Query planes for RGB565
Not all sprite planes support RGB565. Insrtead of hardcoding which platforms have it let's ask the kernel instead. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna')
-rw-r--r--src/sna/sna.h1
-rw-r--r--src/sna/sna_display.c76
-rw-r--r--src/sna/sna_video_sprite.c2
3 files changed, 78 insertions, 1 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h
index 6fe1f0d2..496460ca 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -636,6 +636,7 @@ extern bool sna_crtc_set_sprite_rotation(xf86CrtcPtr crtc, unsigned idx, uint32_
extern void sna_crtc_set_sprite_colorspace(xf86CrtcPtr crtc, unsigned idx, int colorspace);
extern uint32_t sna_crtc_to_sprite(xf86CrtcPtr crtc, unsigned idx);
extern bool sna_crtc_is_transformed(xf86CrtcPtr crtc);
+bool sna_has_sprite_format(struct sna *sna, uint32_t format);
#define CRTC_VBLANK 0x7
#define CRTC_ON 0x80000000
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 66a941ae..96e7b1bc 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -3560,6 +3560,82 @@ sna_crtc_find_planes(struct sna *sna, struct sna_crtc *crtc)
free(planes);
}
+static bool plane_has_format(const uint32_t formats[],
+ int count_formats,
+ uint32_t format)
+{
+ int i;
+
+ for (i = 0; i < count_formats; i++) {
+ if (formats[i] == format)
+ return true;
+ }
+
+ return false;
+}
+
+bool sna_has_sprite_format(struct sna *sna, uint32_t format)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(sna->scrn);
+ int i;
+
+ if (sna->mode.num_real_crtc == 0)
+ return false;
+
+ for (i = 0; i < sna->mode.num_real_crtc; i++) {
+ struct sna_crtc *sna_crtc = to_sna_crtc(config->crtc[i]);
+ struct plane *plane;
+
+ list_for_each_entry(plane, &sna_crtc->sprites, link) {
+ struct local_mode_get_plane p;
+ uint32_t *formats;
+ int count_formats;
+ bool has_format;
+
+ VG_CLEAR(p);
+ p.plane_id = plane->id;
+ p.count_format_types = 0;
+ if (drmIoctl(sna->kgem.fd,
+ LOCAL_IOCTL_MODE_GETPLANE,
+ &p))
+ continue;
+ count_formats = p.count_format_types;
+
+ formats = calloc(count_formats, sizeof(formats[0]));
+ if (!formats)
+ continue;
+
+ p.count_format_types = count_formats;
+ p.format_type_ptr = (uintptr_t)formats;
+ if (drmIoctl(sna->kgem.fd,
+ LOCAL_IOCTL_MODE_GETPLANE,
+ &p)) {
+ free(formats);
+ continue;
+ }
+
+ assert(p.count_format_types == count_formats);
+
+ has_format = plane_has_format(formats,
+ count_formats,
+ format);
+
+ free(formats);
+
+ /*
+ * As long as one plane supports the
+ * format we declare it as supported.
+ * Not all planes may support it, but
+ * then the GPU fallback will kick in.
+ */
+ if (has_format)
+ return true;
+ }
+ }
+
+ return false;
+}
+
static void
sna_crtc_init__rotation(struct sna *sna, struct sna_crtc *crtc)
{
diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c
index 56391aa6..a4f3205b 100644
--- a/src/sna/sna_video_sprite.c
+++ b/src/sna/sna_video_sprite.c
@@ -754,7 +754,7 @@ void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen)
adaptor->pAttributes = (XvAttributeRec *)attribs;
adaptor->pImages = (XvImageRec *)images;
adaptor->nImages = 3;
- if (sna->kgem.gen == 071)
+ if (sna_has_sprite_format(sna, DRM_FORMAT_RGB565))
adaptor->nImages = 4;
#if XORG_XV_VERSION < 2