diff --git a/src/r600_textured_videofuncs.c b/src/r600_textured_videofuncs.c index 2f0b6b1..6c67525 100644 --- a/src/r600_textured_videofuncs.c +++ b/src/r600_textured_videofuncs.c @@ -251,18 +251,26 @@ R600DisplayTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv) accel_state->vs_mc_addr = info->fbLocation + pScrn->fbOffset + accel_state->shaders->offset + accel_state->xv_vs_offset; - accel_state->ps_mc_addr = info->fbLocation + pScrn->fbOffset + accel_state->shaders->offset + - accel_state->xv_ps_offset; - /* PS bool constant */ switch(pPriv->id) { case FOURCC_YV12: case FOURCC_I420: + accel_state->ps_mc_addr = info->fbLocation + pScrn->fbOffset + + accel_state->shaders->offset + accel_state->xv_ps_offset; set_bool_consts(pScrn, accel_state->ib, SQ_BOOL_CONST_ps, (1 << 0)); break; case FOURCC_UYVY: case FOURCC_YUY2: default: + accel_state->ps_mc_addr = info->fbLocation + pScrn->fbOffset + + accel_state->shaders->offset + accel_state->xv_ps_offset; + set_bool_consts(pScrn, accel_state->ib, SQ_BOOL_CONST_ps, (0 << 0)); + break; + case FOURCC_RGBA32: + case FOURCC_RGB16: + case FOURCC_RGBT16: + accel_state->ps_mc_addr = info->fbLocation + pScrn->fbOffset + + accel_state->shaders->offset + accel_state->comp_ps_offset; set_bool_consts(pScrn, accel_state->ib, SQ_BOOL_CONST_ps, (0 << 0)); break; } @@ -468,6 +476,75 @@ R600DisplayTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv) tex_samp.id = 1; set_tex_sampler (pScrn, accel_state->ib, &tex_samp); break; + case FOURCC_RGBA32: + case FOURCC_RGB16: + case FOURCC_RGBT16: + accel_state->src_mc_addr[0] = pPriv->src_offset + info->fbLocation + pScrn->fbOffset; + accel_state->src_size[0] = accel_state->src_pitch[0] * pPriv->h; + + /* flush texture cache */ + cp_set_surface_sync(pScrn, accel_state->ib, TC_ACTION_ENA_bit, accel_state->src_size[0], + accel_state->src_mc_addr[0]); + + /* Y texture */ + tex_res.id = 0; + tex_res.w = pPriv->w; + tex_res.h = pPriv->h; + tex_res.depth = 0; + tex_res.dim = SQ_TEX_DIM_2D; + tex_res.base = accel_state->src_mc_addr[0]; + tex_res.mip_base = accel_state->src_mc_addr[0]; + + tex_res.dst_sel_x = SQ_SEL_Z; + tex_res.dst_sel_y = SQ_SEL_Y; + tex_res.dst_sel_z = SQ_SEL_X; + tex_res.dst_sel_w = SQ_SEL_1; + switch(pPriv->id) { + case FOURCC_RGBA32: + tex_res.pitch = accel_state->src_pitch[0] >> 2; + tex_res.format = FMT_8_8_8_8; + break; + case FOURCC_RGB16: + tex_res.pitch = accel_state->src_pitch[0] >> 1; + tex_res.format = FMT_5_6_5; + break; + case FOURCC_RGBT16: + tex_res.pitch = accel_state->src_pitch[0] >> 1; + tex_res.format = FMT_1_5_5_5; + break; + } + + tex_res.request_size = 1; + tex_res.base_level = 0; + tex_res.last_level = 0; + tex_res.perf_modulation = 0; + tex_res.interlaced = 0; + set_tex_resource (pScrn, accel_state->ib, &tex_res); + + /* Y sampler */ + tex_samp.id = 0; + tex_samp.clamp_x = SQ_TEX_CLAMP_LAST_TEXEL; + tex_samp.clamp_y = SQ_TEX_CLAMP_LAST_TEXEL; + tex_samp.clamp_z = SQ_TEX_WRAP; + + /* xxx: switch to bicubic */ + switch (pPriv->interpolation) + { + case 0: + tex_samp.xy_mag_filter = SQ_TEX_XY_FILTER_POINT; + tex_samp.xy_min_filter = SQ_TEX_XY_FILTER_POINT; + break; + case 1: + default: + tex_samp.xy_mag_filter = SQ_TEX_XY_FILTER_BILINEAR; + tex_samp.xy_min_filter = SQ_TEX_XY_FILTER_BILINEAR; + break; + } + + tex_samp.z_filter = SQ_TEX_Z_FILTER_NONE; + tex_samp.mip_filter = 0; /* no mipmap */ + set_tex_sampler (pScrn, accel_state->ib, &tex_samp); + break; } /* Render setup */ diff --git a/src/radeon_textured_video.c b/src/radeon_textured_video.c index a9d6fc3..bc8aac8 100644 --- a/src/radeon_textured_video.c +++ b/src/radeon_textured_video.c @@ -305,6 +305,10 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn, srcPitch = (width << 1); srcPitch2 = 0; break; + case FOURCC_RGBA32: + srcPitch = width << 2; + dstPitch = ((dst_width << 2) + hw_align) & ~hw_align; + break; } size = dstPitch * dst_height + 2 * dstPitch2 * ((dst_height + 1) >> 1); @@ -316,14 +320,9 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn, } if (pPriv->video_memory == NULL) { - if (info->ChipFamily >= CHIP_FAMILY_R600) - pPriv->video_offset = radeon_legacy_allocate_memory(pScrn, - &pPriv->video_memory, - size * 2, 256); - else - pPriv->video_offset = radeon_legacy_allocate_memory(pScrn, - &pPriv->video_memory, - size * 2, 64); + pPriv->video_offset = radeon_legacy_allocate_memory(pScrn, + &pPriv->video_memory, + size * 2, hw_align + 1); if (pPriv->video_offset == 0) return BadAlloc; @@ -440,6 +439,16 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn, pPriv->src_addr + (top * dstPitch), srcPitch, dstPitch, nlines, width, 2); break; + case FOURCC_RGBA32: + if (info->ChipFamily >= CHIP_FAMILY_R600) + R600CopyData(pScrn, buf + (top * srcPitch), + pPriv->src_addr + (top * dstPitch), + srcPitch, dstPitch, nlines, width * 4, 1); + else + RADEONCopyData(pScrn, buf + (top * srcPitch), + pPriv->src_addr + (top * dstPitch), + srcPitch, dstPitch, nlines, width, 4); + break; } /* update cliplist */ @@ -577,7 +586,7 @@ static XF86AttributeRec Attributes_r500[NUM_ATTRIBUTES_R500+1] = {0, 0, 0, NULL} }; -#define NUM_ATTRIBUTES_R600 6 +#define NUM_ATTRIBUTES_R600 7 static XF86AttributeRec Attributes_r600[NUM_ATTRIBUTES_R600+1] = { @@ -587,6 +596,7 @@ static XF86AttributeRec Attributes_r600[NUM_ATTRIBUTES_R600+1] = {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"}, {XvSettable | XvGettable, -1000, 1000, "XV_HUE"}, {XvSettable | XvGettable, 0, 1, "XV_COLORSPACE"}, + {XvSettable | XvGettable, 0, 1, "XV_INTERPOLATION"}, {0, 0, 0, NULL} }; @@ -594,6 +604,7 @@ static Atom xvBicubic; static Atom xvVSync; static Atom xvBrightness, xvContrast, xvSaturation, xvHue; static Atom xvGamma, xvColorspace; +static Atom xvInterpolation; #define NUM_IMAGES 4 @@ -605,6 +616,17 @@ static XF86ImageRec Images[NUM_IMAGES] = XVIMAGE_UYVY }; +static XF86ImageRec R600Images[] = +{ + XVIMAGE_RGBA32(LSBFirst), + XVIMAGE_RGB16(LSBFirst), + XVIMAGE_RGBT16(LSBFirst), + XVIMAGE_YUY2, + XVIMAGE_UYVY, + XVIMAGE_YV12, + XVIMAGE_I420 +}; + int RADEONGetTexPortAttribute(ScrnInfoPtr pScrn, Atom attribute, @@ -632,6 +654,8 @@ RADEONGetTexPortAttribute(ScrnInfoPtr pScrn, *value = pPriv->gamma; else if(attribute == xvColorspace) *value = pPriv->transform_index; + else if(attribute == xvInterpolation) + *value = pPriv->interpolation; else return BadMatch; @@ -665,6 +689,8 @@ RADEONSetTexPortAttribute(ScrnInfoPtr pScrn, pPriv->gamma = ClipValue (value, 100, 10000); else if(attribute == xvColorspace) pPriv->transform_index = ClipValue (value, 0, 1); + else if(attribute == xvInterpolation) + pPriv->interpolation = ClipValue (value, 0, 1); else return BadMatch; @@ -743,6 +769,7 @@ RADEONSetupImageTexturedVideo(ScreenPtr pScreen) xvHue = MAKE_ATOM("XV_HUE"); xvGamma = MAKE_ATOM("XV_GAMMA"); xvColorspace = MAKE_ATOM("XV_COLORSPACE"); + xvInterpolation = MAKE_ATOM("XV_INTERPOLATION"); adapt->type = XvWindowMask | XvInputMask | XvImageMask; adapt->flags = 0; @@ -782,8 +809,13 @@ RADEONSetupImageTexturedVideo(ScreenPtr pScreen) adapt->pAttributes = Attributes; adapt->nAttributes = NUM_ATTRIBUTES; } - adapt->pImages = Images; - adapt->nImages = NUM_IMAGES; + if (IS_R600_3D) { + adapt->pImages = R600Images; + adapt->nImages = RADEON_ARRAY_SIZE(R600Images); + } else { + adapt->pImages = Images; + adapt->nImages = NUM_IMAGES; + } adapt->PutVideo = NULL; adapt->PutStill = NULL; adapt->GetVideo = NULL; @@ -811,6 +843,7 @@ RADEONSetupImageTexturedVideo(ScreenPtr pScreen) pPriv->hue = 0; pPriv->gamma = 1000; pPriv->transform_index = 0; + pPriv->interpolation = 1; /* gotta uninit this someplace, XXX: shouldn't be necessary for textured */ REGION_NULL(pScreen, &pPriv->clip); diff --git a/src/radeon_video.c b/src/radeon_video.c index f1fe72b..a7cb88f 100644 --- a/src/radeon_video.c +++ b/src/radeon_video.c @@ -431,84 +431,6 @@ static XF86AttributeRec Attributes[NUM_DEC_ATTRIBUTES+1] = #define NUM_IMAGES 8 -/* Note: GUIDs are bogus... - but nothing uses them anyway */ - -#define FOURCC_RGBA32 0x41424752 - -#define XVIMAGE_RGBA32(byte_order) \ - { \ - FOURCC_RGBA32, \ - XvRGB, \ - byte_order, \ - { 'R', 'G', 'B', 'A', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 32, \ - XvPacked, \ - 1, \ - 32, 0x00FF0000, 0x0000FF00, 0x000000FF, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, \ - {'A', 'R', 'G', 'B', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#define FOURCC_RGB24 0x00000000 - -#define XVIMAGE_RGB24 \ - { \ - FOURCC_RGB24, \ - XvRGB, \ - LSBFirst, \ - { 'R', 'G', 'B', 0, \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 24, \ - XvPacked, \ - 1, \ - 24, 0x00FF0000, 0x0000FF00, 0x000000FF, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, \ - { 'R', 'G', 'B', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#define FOURCC_RGBT16 0x54424752 - -#define XVIMAGE_RGBT16(byte_order) \ - { \ - FOURCC_RGBT16, \ - XvRGB, \ - byte_order, \ - { 'R', 'G', 'B', 'T', \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 16, \ - XvPacked, \ - 1, \ - 16, 0x00007C00, 0x000003E0, 0x0000001F, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, \ - {'A', 'R', 'G', 'B', \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - -#define FOURCC_RGB16 0x32424752 - -#define XVIMAGE_RGB16(byte_order) \ - { \ - FOURCC_RGB16, \ - XvRGB, \ - byte_order, \ - { 'R', 'G', 'B', 0x00, \ - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ - 16, \ - XvPacked, \ - 1, \ - 16, 0x0000F800, 0x000007E0, 0x0000001F, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, \ - {'R', 'G', 'B', \ - 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ - XvTopToBottom \ - } - static XF86ImageRec Images[NUM_IMAGES] = { #if X_BYTE_ORDER == X_BIG_ENDIAN @@ -3070,17 +2992,23 @@ RADEONQueryImageAttributes( unsigned short *w, unsigned short *h, int *pitches, int *offsets ){ - int size, tmp; + RADEONInfoPtr info = RADEONPTR(pScrn); + int max, size, tmp; + + if (IS_R600_3D) + max = 8192; + else + max = 2048; - if(*w > 2048) *w = 2048; - if(*h > 2048) *h = 2048; + if(*w > max) *w = max; + if(*h > max) *h = max; - *w = (*w + 1) & ~1; if(offsets) offsets[0] = 0; switch(id) { case FOURCC_YV12: case FOURCC_I420: + *w = (*w + 1) & ~1; *h = (*h + 1) & ~1; size = (*w + 3) & ~3; if(pitches) pitches[0] = size; @@ -3103,10 +3031,11 @@ RADEONQueryImageAttributes( if(pitches) pitches[0] = size; size *= *h; break; - case FOURCC_RGBT16: - case FOURCC_RGB16: case FOURCC_UYVY: case FOURCC_YUY2: + *w = (*w + 1) & ~1; + case FOURCC_RGBT16: + case FOURCC_RGB16: default: size = *w << 1; if(pitches) pitches[0] = size; diff --git a/src/radeon_video.h b/src/radeon_video.h index 989942c..6d69732 100644 --- a/src/radeon_video.h +++ b/src/radeon_video.h @@ -28,6 +28,7 @@ typedef struct { int red_intensity; int green_intensity; int blue_intensity; + int interpolation; /* overlay composition mode */ int alpha_mode; /* 0 = key mode, 1 = global mode */ @@ -140,6 +141,84 @@ typedef struct tagREF_TRANSFORM #define RTFContrast(a) (1.0 + ((a)*1.0)/1000.0) #define RTFHue(a) (((a)*3.1416)/1000.0) +/* Note: GUIDs are bogus... - but nothing uses them anyway */ + +#define FOURCC_RGBA32 0x41424752 + +#define XVIMAGE_RGBA32(byte_order) \ + { \ + FOURCC_RGBA32, \ + XvRGB, \ + byte_order, \ + { 'R', 'G', 'B', 'A', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 32, \ + XvPacked, \ + 1, \ + 32, 0x00FF0000, 0x0000FF00, 0x000000FF, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + {'A', 'R', 'G', 'B', \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + XvTopToBottom \ + } + +#define FOURCC_RGB24 0x00000000 + +#define XVIMAGE_RGB24 \ + { \ + FOURCC_RGB24, \ + XvRGB, \ + LSBFirst, \ + { 'R', 'G', 'B', 0, \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 24, \ + XvPacked, \ + 1, \ + 24, 0x00FF0000, 0x0000FF00, 0x000000FF, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + { 'R', 'G', 'B', \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + XvTopToBottom \ + } + +#define FOURCC_RGBT16 0x54424752 + +#define XVIMAGE_RGBT16(byte_order) \ + { \ + FOURCC_RGBT16, \ + XvRGB, \ + byte_order, \ + { 'R', 'G', 'B', 'T', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 16, \ + XvPacked, \ + 1, \ + 16, 0x00007C00, 0x000003E0, 0x0000001F, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + {'A', 'R', 'G', 'B', \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + XvTopToBottom \ + } + +#define FOURCC_RGB16 0x32424752 + +#define XVIMAGE_RGB16(byte_order) \ + { \ + FOURCC_RGB16, \ + XvRGB, \ + byte_order, \ + { 'R', 'G', 'B', 0x00, \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 16, \ + XvPacked, \ + 1, \ + 16, 0x0000F800, 0x000007E0, 0x0000001F, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + {'R', 'G', 'B', \ + 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + XvTopToBottom \ + } + xf86CrtcPtr radeon_xv_pick_best_crtc(ScrnInfoPtr pScrn, int x1, int x2, int y1, int y2);