Commit 9c281c62 authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Chris Wilson
Browse files

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ä's avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
parent d2a21702
......@@ -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
......
......@@ -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)
{
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment