<div dir="ltr">FYI this and the radeonsi patch assume that the kernel driver with UVD support reports version 2.31.0 (needs to be bumped)<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/3 Andreas Boll <span dir="ltr"><<a href="mailto:andreas.boll.dev@gmail.com" target="_blank">andreas.boll.dev@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Cc: Christian König <<a href="mailto:deathsimple@vodafone.de">deathsimple@vodafone.de</a>><br>
---<br>
 src/gallium/drivers/r600/r600_pipe.c |   63 +++++++++++++++++++++++++++++++---<br>
 src/gallium/drivers/r600/r600_pipe.h |    1 +<br>
 2 files changed, 60 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c<br>
index 5b82aed..7a80661 100644<br>
--- a/src/gallium/drivers/r600/r600_pipe.c<br>
+++ b/src/gallium/drivers/r600/r600_pipe.c<br>
@@ -380,8 +380,13 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void<br>
        r600_init_context_resource_functions(rctx);<br>
        r600_init_surface_functions(rctx);<br>
<br>
-       rctx->context.create_video_decoder = r600_uvd_create_decoder;<br>
-       rctx->context.create_video_buffer = r600_video_buffer_create;<br>
+       if (rscreen->has_uvd) {<br>
+               rctx->context.create_video_decoder = r600_uvd_create_decoder;<br>
+               rctx->context.create_video_buffer = r600_video_buffer_create;<br>
+       } else {<br>
+               rctx->context.create_video_decoder = vl_create_decoder;<br>
+               rctx->context.create_video_buffer = vl_video_buffer_create;<br>
+       }<br>
<br>
        r600_init_common_state_functions(rctx);<br>
<br>
@@ -787,6 +792,31 @@ static int r600_get_video_param(struct pipe_screen *screen,<br>
        }<br>
 }<br>
<br>
+static int r600_get_video_param_fallback(struct pipe_screen *screen,<br>
+                               enum pipe_video_profile profile,<br>
+                               enum pipe_video_cap param)<br>
+{<br>
+       switch (param) {<br>
+       case PIPE_VIDEO_CAP_SUPPORTED:<br>
+               return vl_profile_supported(screen, profile);<br>
+       case PIPE_VIDEO_CAP_NPOT_TEXTURES:<br>
+               return 1;<br>
+       case PIPE_VIDEO_CAP_MAX_WIDTH:<br>
+       case PIPE_VIDEO_CAP_MAX_HEIGHT:<br>
+               return vl_video_buffer_max_size(screen);<br>
+       case PIPE_VIDEO_CAP_PREFERED_FORMAT:<br>
+               return PIPE_FORMAT_NV12;<br>
+       case PIPE_VIDEO_CAP_PREFERS_INTERLACED:<br>
+               return false;<br>
+       case PIPE_VIDEO_CAP_SUPPORTS_INTERLACED:<br>
+               return false;<br>
+       case PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE:<br>
+               return true;<br>
+       default:<br>
+               return 0;<br>
+       }<br>
+}<br>
+<br>
 static int r600_get_compute_param(struct pipe_screen *screen,<br>
         enum pipe_compute_cap param,<br>
         void *ret)<br>
@@ -1214,6 +1244,19 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)<br>
        rscreen->has_cp_dma = rscreen->info.drm_minor >= 27 &&<br>
                              !(rscreen->debug_flags & DBG_NO_CP_DMA);<br>
<br>
+       /* UVD support. */<br>
+       switch (rscreen->chip_class) {<br>
+       /* The R6xx and RS780/RS880 chipset generations are currently not supported, but might be added in the future. */<br>
+       case R700:<br>
+       case EVERGREEN:<br>
+       case CAYMAN:<br>
+               rscreen->has_uvd = rscreen->info.drm_minor >= 31;<br>
+               break;<br>
+       default:<br>
+               rscreen->has_uvd = FALSE;<br>
+               break;<br>
+       }<br>
+<br>
        if (r600_init_tiling(rscreen)) {<br>
                FREE(rscreen);<br>
                return NULL;<br>
@@ -1225,7 +1268,13 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)<br>
        rscreen->screen.get_param = r600_get_param;<br>
        rscreen->screen.get_shader_param = r600_get_shader_param;<br>
        rscreen->screen.get_paramf = r600_get_paramf;<br>
-       rscreen->screen.get_video_param = r600_get_video_param;<br>
+<br>
+       if (rscreen->has_uvd) {<br>
+               rscreen->screen.get_video_param = r600_get_video_param;<br>
+       } else {<br>
+               rscreen->screen.get_video_param = r600_get_video_param_fallback;<br>
+       }<br>
+<br>
        rscreen->screen.get_compute_param = r600_get_compute_param;<br>
        rscreen->screen.get_timestamp = r600_get_timestamp;<br>
<br>
@@ -1236,7 +1285,13 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)<br>
                rscreen->screen.is_format_supported = r600_is_format_supported;<br>
                rscreen->dma_blit = &r600_dma_blit;<br>
        }<br>
-       rscreen->screen.is_video_format_supported = r600_is_video_format_supported;<br>
+<br>
+       if (rscreen->has_uvd) {<br>
+               rscreen->screen.is_video_format_supported = r600_is_video_format_supported;<br>
+       } else {<br>
+               rscreen->screen.is_video_format_supported = vl_video_buffer_is_format_supported;<br>
+       }<br>
+<br>
        rscreen->screen.context_create = r600_create_context;<br>
        rscreen->screen.fence_reference = r600_fence_reference;<br>
        rscreen->screen.fence_signalled = r600_fence_signalled;<br>
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h<br>
index f3433e7..944f9fe 100644<br>
--- a/src/gallium/drivers/r600/r600_pipe.h<br>
+++ b/src/gallium/drivers/r600/r600_pipe.h<br>
@@ -273,6 +273,7 @@ struct r600_screen {<br>
        bool                            has_streamout;<br>
        bool                            has_msaa;<br>
        bool                            has_cp_dma;<br>
+       bool                            has_uvd;<br>
        enum r600_msaa_texture_mode     msaa_texture_support;<br>
        struct r600_tiling_info         tiling_info;<br>
        struct r600_pipe_fences         fences;<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.10.4<br>
<br>
</font></span></blockquote></div><br></div>