VIA gfx driver: overlay engine on K8M800 responds now, wip.

This commit is contained in:
Rudolf Cornelissen 2016-01-23 23:44:37 +01:00
parent 8376bc1bc1
commit 0fa7d5c4df
2 changed files with 240 additions and 104 deletions

View File

@ -705,6 +705,7 @@
#define ENBES_HI_TRANSP_COL 0x00000270 #define ENBES_HI_TRANSP_COL 0x00000270
#define ENBES_V3A_FIFO 0x00000278 #define ENBES_V3A_FIFO 0x00000278
#define ENBES_V3_SRC_WIDTH 0x0000027c #define ENBES_V3_SRC_WIDTH 0x0000027c
#define ENBES_V3_COLKEY 0x00000280
#define ENBES_VID1_COLSPAC1 0x00000284 #define ENBES_VID1_COLSPAC1 0x00000284
#define ENBES_VID1_COLSPAC2 0x00000288 #define ENBES_VID1_COLSPAC2 0x00000288
#define ENBES_VID1U_ADDR0 0x0000028c #define ENBES_VID1U_ADDR0 0x0000028c
@ -714,14 +715,14 @@
#define ENBES_VID3_CTL 0x000002a0 #define ENBES_VID3_CTL 0x000002a0
#define ENBES_VID3_ADDR0 0x000002a4 #define ENBES_VID3_ADDR0 0x000002a4
#define ENBES_VID3_ADDR1 0x000002a8 #define ENBES_VID3_ADDR1 0x000002a8
#define ENBES_VID3_STRIBE 0x000002ac #define ENBES_VID3_STRIDE 0x000002ac
#define ENBES_VID3_HVSTART 0x000002b0 #define ENBES_VID3_HVSTART 0x000002b0
#define ENBES_VID3_SIZE 0x000002b4 #define ENBES_VID3_SIZE 0x000002b4
#define ENBES_V3A_FETCH 0x000002b8 #define ENBES_V3A_FETCH 0x000002b8
#define ENBES_VID3_ZOOM 0x000002bc #define ENBES_VID3_ZOOM 0x000002bc
#define ENBES_VID3_MICTL 0x000002c0 #define ENBES_VID3_MINI_CTL 0x000002c0
#define ENBES_VID3_CSC1 0x000002c4 #define ENBES_VID3_COLSPAC1 0x000002c4
#define ENBES_VID3_CSC2 0x000002c8 #define ENBES_VID3_COLSPAC2 0x000002c8
#define ENBES_VID1U_ADDR1 0x000002e4 #define ENBES_VID1U_ADDR1 0x000002e4
#define ENBES_VID1U_ADDR2 0x000002e8 #define ENBES_VID1U_ADDR2 0x000002e8
#define ENBES_VID1U_ADDR3 0x000002ec #define ENBES_VID1U_ADDR3 0x000002ec

View File

@ -1,5 +1,5 @@
/* VIA Unichrome Back End Scaler functions */ /* VIA Unichrome Back End Scaler functions */
/* Written by Rudolf Cornelissen 05/2002-1/2006 */ /* Written by Rudolf Cornelissen 05/2002-1/2016 */
#define MODULE_BIT 0x00000200 #define MODULE_BIT 0x00000200
@ -396,31 +396,62 @@ static void eng_bes_program_move_overlay(move_overlay_info moi)
*** actually program the registers *** *** actually program the registers ***
**************************************/ **************************************/
/* setup clipped(!) buffer startadress in RAM */ if (si->ps.card_arch < K8M800)
/* VIA bes doesn't have clipping registers, so no subpixelprecise clipping {
* either. We do pixelprecise vertical and 'two pixel' precise horizontal clipping here. */ /* setup clipped(!) buffer startadress in RAM */
/* first include 'pixel precise' left clipping... (top clipping was already included) */ /* VIA bes doesn't have clipping registers, so no subpixelprecise clipping
moi.a1orgv += ((moi.hsrcstv >> 16) * 2); * either. We do pixelprecise vertical and 'two pixel' precise horizontal clipping here. */
/* we need to step in 4-byte (2 pixel) granularity due to the nature of yuy2 */ /* first include 'pixel precise' left clipping... (top clipping was already included) */
BESW(VID1Y_ADDR0, (moi.a1orgv & 0x07fffffc)); moi.a1orgv += ((moi.hsrcstv >> 16) * 2);
/* we need to step in 4-byte (2 pixel) granularity due to the nature of yuy2 */
BESW(VID1Y_ADDR0, (moi.a1orgv & 0x07fffffc));
/* horizontal source end does not use subpixelprecision: granularity is 8 pixels */ /* horizontal source end does not use subpixelprecision: granularity is 8 pixels */
/* notes: /* notes:
* - make absolutely sure the engine can fetch the last pixel needed from * - make absolutely sure the engine can fetch the last pixel needed from
* the sourcebitmap even if only to generate a tiny subpixel from it! * the sourcebitmap even if only to generate a tiny subpixel from it!
* - the engine uses byte format instead of pixel format; * - the engine uses byte format instead of pixel format;
* - the engine uses 16 bytes, so 8 pixels granularity. */ * - the engine uses 16 bytes, so 8 pixels granularity. */
BESW(VID1_FETCH, (((((moi.hsrcendv >> 16) + 1 + 0x0007) & ~0x0007) * 2) << (20 - 4))); BESW(VID1_FETCH, (((((moi.hsrcendv >> 16) + 1 + 0x0007) & ~0x0007) * 2) << (20 - 4)));
/* setup output window position */ /* setup output window position */
BESW(VID1_HVSTART, ((moi.hcoordv & 0xffff0000) | ((moi.vcoordv & 0xffff0000) >> 16))); BESW(VID1_HVSTART, ((moi.hcoordv & 0xffff0000) | ((moi.vcoordv & 0xffff0000) >> 16)));
/* setup output window size */ /* setup output window size */
BESW(VID1_SIZE, (((moi.hcoordv & 0x0000ffff) << 16) | (moi.vcoordv & 0x0000ffff))); BESW(VID1_SIZE, (((moi.hcoordv & 0x0000ffff) << 16) | (moi.vcoordv & 0x0000ffff)));
/* enable colorkeying (b0 = 1), disable chromakeying (b1 = 0), Vid1 on top of Vid3 (b20 = 0), /* enable colorkeying (b0 = 1), disable chromakeying (b1 = 0), Vid1 on top of Vid3 (b20 = 0),
* all registers are loaded during the next 'BES-'VBI (b28 = 1), Vid1 cmds fire (b31 = 1) */ * all registers are loaded during the next 'BES-'VBI (b28 = 1), Vid1 cmds fire (b31 = 1) */
BESW(COMPOSE, 0x90000001); BESW(COMPOSE, 0x90000001);//fixme: >>>!<<< don't touch colorkey enable bit!
}
else
{
/* setup clipped(!) buffer startadress in RAM */
/* VIA bes doesn't have clipping registers, so no subpixelprecise clipping
* either. We do pixelprecise vertical and 'two pixel' precise horizontal clipping here. */
/* first include 'pixel precise' left clipping... (top clipping was already included) */
moi.a1orgv += ((moi.hsrcstv >> 16) * 2);
/* we need to step in 4-byte (2 pixel) granularity due to the nature of yuy2 */
BESW(VID3_ADDR0, (moi.a1orgv & 0x07fffffc));
/* horizontal source end does not use subpixelprecision: granularity is 8 pixels */
/* notes:
* - make absolutely sure the engine can fetch the last pixel needed from
* the sourcebitmap even if only to generate a tiny subpixel from it!
* - the engine uses byte format instead of pixel format;
* - the engine uses 16 bytes, so 8 pixels granularity. */
//BESW(VID1_FETCH, (((((moi.hsrcendv >> 16) + 1 + 0x0007) & ~0x0007) * 2) << (20 - 4)));
/* setup output window position */
BESW(VID3_HVSTART, ((moi.hcoordv & 0xffff0000) | ((moi.vcoordv & 0xffff0000) >> 16)));
/* setup output window size */
BESW(VID3_SIZE, (((moi.hcoordv & 0x0000ffff) << 16) | (moi.vcoordv & 0x0000ffff)));
/* enable colorkeying (b0 = 1), disable chromakeying (b1 = 0), Vid3 on top of Vid1 (b20 = 1),
* all registers are loaded during the next 'BES-'VBI (b8 = 1), Vid3 cmds fire (b30 = 1) */
BESW(COMPOSE, 0x40100101);//fixme: >>>!<<< don't touch colorkey enable bit!
}
} }
status_t eng_bes_to_crtc(bool crtc) status_t eng_bes_to_crtc(bool crtc)
@ -453,21 +484,32 @@ status_t eng_bes_to_crtc(bool crtc)
status_t eng_bes_init() status_t eng_bes_init()
{ {
if (si->ps.chip_rev < 0x10) if (si->ps.card_arch < K8M800)
{ {
/* select colorspace setup for B_YCbCr422 */ if (si->ps.chip_rev < 0x10)
BESW(VID1_COLSPAC1, 0x140020f2); {
BESW(VID1_COLSPAC2, 0x0a0a2c00); /* select colorspace setup for B_YCbCr422 */
/* fifo depth is $20 (b0-5), threshold $10 (b8-13), prethreshold $1d (b24-29) */ BESW(VID1_COLSPAC1, 0x140020f2);
BESW(VID1_FIFO, 0x1d00101f); BESW(VID1_COLSPAC2, 0x0a0a2c00);
/* fifo depth is $20 (b0-5), threshold $10 (b8-13), prethreshold $1d (b24-29) */
BESW(VID1_FIFO, 0x1d00101f);
}
else
{
/* select colorspace setup for B_YCbCr422 */
BESW(VID1_COLSPAC1, 0x13000ded);
BESW(VID1_COLSPAC2, 0x13171000);
/* fifo depth is $40 (b0-5), threshold $38 (b8-13), prethreshold $38 (b24-29) */
BESW(VID1_FIFO, 0x3800383f);
}
} }
else else
{ {
/* select colorspace setup for B_YCbCr422 */ /* select colorspace setup for B_YCbCr422 */
BESW(VID1_COLSPAC1, 0x13000ded); BESW(VID3_COLSPAC1, 0x140020f2);
BESW(VID1_COLSPAC2, 0x13171000); BESW(VID3_COLSPAC2, 0x0a0a2c00);
/* fifo depth is $40 (b0-5), threshold $38 (b8-13), prethreshold $38 (b24-29) */ /* fifo depth is $20 (b0-5), threshold $10 (b8-13), prethreshold $1d (b24-29) */
BESW(VID1_FIFO, 0x3800383f); //BESW(VID1_FIFO, 0x1d00101f);
} }
/* disable overlay ints (b0 = buffer 0, b4 = buffer 1) */ /* disable overlay ints (b0 = buffer 0, b4 = buffer 1) */
@ -793,72 +835,135 @@ status_t eng_configure_bes
*** actually program the registers *** *** actually program the registers ***
**************************************/ **************************************/
/* setup clipped(!) buffer startadress in RAM */ if (si->ps.card_arch < K8M800)
/* VIA bes doesn't have clipping registers, so no subpixelprecise clipping
* either. We do pixelprecise vertical and 'two pixel' precise horizontal clipping here. */
/* first include 'pixel precise' left clipping... (top clipping was already included) */
moi.a1orgv += ((moi.hsrcstv >> 16) * 2);
/* we need to step in 4-byte (2 pixel) granularity due to the nature of yuy2 */
BESW(VID1Y_ADDR0, (moi.a1orgv & 0x07fffffc));
/* horizontal source end does not use subpixelprecision: granularity is 8 pixels */
/* notes:
* - make absolutely sure the engine can fetch the last pixel needed from
* the sourcebitmap even if only to generate a tiny subpixel from it!
* - the engine uses byte format instead of pixel format;
* - the engine uses 16 bytes, so 8 pixels granularity. */
BESW(VID1_FETCH, (((((moi.hsrcendv >> 16) + 1 + 0x0007) & ~0x0007) * 2) << (20 - 4)));
/* enable horizontal filtering if asked for */
if (ow->flags & B_OVERLAY_HORIZONTAL_FILTERING)
{ {
minictrl |= (1 << 1); /* setup clipped(!) buffer startadress in RAM */
LOG(4,("Overlay: using horizontal interpolation on scaling\n")); /* VIA bes doesn't have clipping registers, so no subpixelprecise clipping
} * either. We do pixelprecise vertical and 'two pixel' precise horizontal clipping here. */
/* enable vertical filtering if asked for */ /* first include 'pixel precise' left clipping... (top clipping was already included) */
if (ow->flags & B_OVERLAY_VERTICAL_FILTERING) moi.a1orgv += ((moi.hsrcstv >> 16) * 2);
{ /* we need to step in 4-byte (2 pixel) granularity due to the nature of yuy2 */
/* vertical interpolation b0, interpolation on Y, Cb and Cr all (b2) */ BESW(VID1Y_ADDR0, (moi.a1orgv & 0x07fffffc));
minictrl |= ((1 << 2) | (1 << 0));
LOG(4,("Overlay: using vertical interpolation on scaling\n"));
}
/* and program horizontal and vertical 'prescaling' for downscaling */
BESW(VID1_MINI_CTL, minictrl);
/* setup buffersize */ /* horizontal source end does not use subpixelprecision: granularity is 8 pixels */
BESW(V1_SOURCE_WH, ((ob->height << 16) | (ob->width))); /* notes:
* - make absolutely sure the engine can fetch the last pixel needed from
* the sourcebitmap even if only to generate a tiny subpixel from it!
* - the engine uses byte format instead of pixel format;
* - the engine uses 16 bytes, so 8 pixels granularity. */
BESW(VID1_FETCH, (((((moi.hsrcendv >> 16) + 1 + 0x0007) & ~0x0007) * 2) << (20 - 4)));
/* setup buffer source pitch including slopspace (in bytes) */ /* enable horizontal filtering if asked for */
BESW(VID1_STRIDE, (ob->width * 2)); if (ow->flags & B_OVERLAY_HORIZONTAL_FILTERING)
{
minictrl |= (1 << 1);
LOG(4,("Overlay: using horizontal interpolation on scaling\n"));
}
/* enable vertical filtering if asked for */
if (ow->flags & B_OVERLAY_VERTICAL_FILTERING)
{
/* vertical interpolation b0, interpolation on Y, Cb and Cr all (b2) */
minictrl |= ((1 << 2) | (1 << 0));
LOG(4,("Overlay: using vertical interpolation on scaling\n"));
}
/* and program horizontal and vertical 'prescaling' for downscaling */
BESW(VID1_MINI_CTL, minictrl);
/* setup output window position */ /* setup buffersize */
BESW(VID1_HVSTART, ((moi.hcoordv & 0xffff0000) | ((moi.vcoordv & 0xffff0000) >> 16))); BESW(V1_SOURCE_WH, ((ob->height << 16) | (ob->width)));
/* setup output window size */ /* setup buffer source pitch including slopspace (in bytes) */
BESW(VID1_SIZE, (((moi.hcoordv & 0x0000ffff) << 16) | (moi.vcoordv & 0x0000ffff))); BESW(VID1_STRIDE, (ob->width * 2));
/* setup horizontal and vertical scaling: /* setup output window position */
* setup horizontal scaling enable (b31), setup vertical scaling enable (b15). BESW(VID1_HVSTART, ((moi.hcoordv & 0xffff0000) | ((moi.vcoordv & 0xffff0000) >> 16)));
* Note:
* Vertical scaling has a different resolution than horizontal scaling(!). */
scaleval = 0x00000000;
if (scale_x) scaleval |= 0x80000000;
if (scale_y) scaleval |= 0x00008000;
BESW(VID1_ZOOM, (scaleval | ((hiscalv << 16) >> 5) | (viscalv >> 6)));
if (si->ps.chip_rev < 0x10) /* setup output window size */
{ BESW(VID1_SIZE, (((moi.hcoordv & 0x0000ffff) << 16) | (moi.vcoordv & 0x0000ffff)));
/* enable BES (b0), format yuv422 (b2-4 = %000), set colorspace sign (b7 = 1),
* input is frame (not field) picture (b9 = 0), expire = $5 (b16-19), /* setup horizontal and vertical scaling:
* select field (not frame)(!) base (b24 = 0) */ * setup horizontal scaling enable (b31), setup vertical scaling enable (b15).
BESW(VID1_CTL, 0x00050081); * Note:
* Vertical scaling has a different resolution than horizontal scaling(!). */
scaleval = 0x00000000;
if (scale_x) scaleval |= 0x80000000;
if (scale_y) scaleval |= 0x00008000;
BESW(VID1_ZOOM, (scaleval | ((hiscalv << 16) >> 5) | (viscalv >> 6)));
if (si->ps.chip_rev < 0x10)
{
/* enable BES (b0), format yuv422 (b2-4 = %000), set colorspace sign (b7 = 1),
* input is frame (not field) picture (b9 = 0), expire = $5 (b16-19),
* select field (not frame)(!) base (b24 = 0) */
BESW(VID1_CTL, 0x00050081);
}
else
{
/* enable BES (b0), format yuv422 (b2-4 = %000), set colorspace sign (b7 = 1),
* input is frame (not field) picture (b9 = 0), expire = $f (b16-19),
* select field (not frame)(!) base (b24 = 0) */
BESW(VID1_CTL, 0x000f0081);
}
} }
else else
{ {
/* enable BES (b0), format yuv422 (b2-4 = %000), set colorspace sign (b7 = 1), /* setup clipped(!) buffer startadress in RAM */
* input is frame (not field) picture (b9 = 0), expire = $f (b16-19), /* VIA bes doesn't have clipping registers, so no subpixelprecise clipping
* select field (not frame)(!) base (b24 = 0) */ * either. We do pixelprecise vertical and 'two pixel' precise horizontal clipping here. */
BESW(VID1_CTL, 0x000f0081); /* first include 'pixel precise' left clipping... (top clipping was already included) */
moi.a1orgv += ((moi.hsrcstv >> 16) * 2);
/* we need to step in 4-byte (2 pixel) granularity due to the nature of yuy2 */
BESW(VID3_ADDR0, (moi.a1orgv & 0x07fffffc));
/* horizontal source end does not use subpixelprecision: granularity is 8 pixels */
/* notes:
* - make absolutely sure the engine can fetch the last pixel needed from
* the sourcebitmap even if only to generate a tiny subpixel from it!
* - the engine uses byte format instead of pixel format;
* - the engine uses 16 bytes, so 8 pixels granularity. */
//BESW(VID1_FETCH, (((((moi.hsrcendv >> 16) + 1 + 0x0007) & ~0x0007) * 2) << (20 - 4)));
/* enable horizontal filtering if asked for */
if (ow->flags & B_OVERLAY_HORIZONTAL_FILTERING)
{
minictrl |= (1 << 1);
LOG(4,("Overlay: using horizontal interpolation on scaling\n"));
}
/* enable vertical filtering if asked for */
if (ow->flags & B_OVERLAY_VERTICAL_FILTERING)
{
/* vertical interpolation b0, interpolation on Y, Cb and Cr all (b2) */
minictrl |= ((1 << 2) | (1 << 0));
LOG(4,("Overlay: using vertical interpolation on scaling\n"));
}
/* and program horizontal and vertical 'prescaling' for downscaling */
BESW(VID3_MINI_CTL, minictrl);
/* setup buffersize */
BESW(V3_SRC_WIDTH, ((ob->height << 16) | (ob->width))); //fixme >>>!<<< height??
/* setup buffer source pitch including slopspace (in bytes) */
BESW(VID3_STRIDE, (ob->width * 2));
/* setup output window position */
BESW(VID3_HVSTART, ((moi.hcoordv & 0xffff0000) | ((moi.vcoordv & 0xffff0000) >> 16)));
/* setup output window size */
BESW(VID3_SIZE, (((moi.hcoordv & 0x0000ffff) << 16) | (moi.vcoordv & 0x0000ffff)));
/* setup horizontal and vertical scaling:
* setup horizontal scaling enable (b31), setup vertical scaling enable (b15).
* Note:
* Vertical scaling has a different resolution than horizontal scaling(!). */
scaleval = 0x00000000;
if (scale_x) scaleval |= 0x80000000;
if (scale_y) scaleval |= 0x00008000;
BESW(VID3_ZOOM, (scaleval | ((hiscalv << 16) >> 5) | (viscalv >> 6)));
/* enable BES (b0), format yuv422 (b2-3 = %00), set colorspace sign (b7 = 1),
* expire = $8 (b16-19), select field (not frame)(!) base (b24 = 0),
* enable prefetch (b30 = 1) */
BESW(VID3_CTL, 0x40080081);
} }
@ -926,17 +1031,35 @@ status_t eng_configure_bes
break; break;
} }
/* disable chromakeying (b1 = 0), Vid1 on top of Vid3 (b20 = 0), if (si->ps.card_arch < K8M800)
* all registers are loaded during the next 'BES-'VBI (b28 = 1), Vid1 cmds fire (b31 = 1) */
if (ow->flags & B_OVERLAY_COLOR_KEY)
{ {
/* enable colorkeying (b0 = 1) */ /* disable chromakeying (b1 = 0), Vid1 on top of Vid3 (b20 = 0),
BESW(COMPOSE, 0x90000001); * all registers are loaded during the next 'BES-'VBI (b28 = 1), Vid1 cmds fire (b31 = 1) */
if (ow->flags & B_OVERLAY_COLOR_KEY)
{
/* enable colorkeying (b0 = 1) */
BESW(COMPOSE, 0x90000001);
}
else
{
/* disable colorkeying (b0 = 0) */
BESW(COMPOSE, 0x90000000);
}
} }
else else
{ {
/* disable colorkeying (b0 = 0) */ /* disable chromakeying (b1 = 0), Vid3 on top of Vid1 (b20 = 1),
BESW(COMPOSE, 0x90000000); * all registers are loaded during the next 'BES-'VBI (b8 = 1), Vid3 cmds fire (b30 = 1) */
if (ow->flags & B_OVERLAY_COLOR_KEY)
{
/* enable colorkeying (b0 = 1) */
BESW(COMPOSE, 0x40100101);
}
else
{
/* disable colorkeying (b0 = 0) */
BESW(COMPOSE, 0x40100100);
}
} }
/* note that overlay is in use (for eng_bes_move_overlay()) */ /* note that overlay is in use (for eng_bes_move_overlay()) */
@ -947,12 +1070,24 @@ status_t eng_configure_bes
status_t eng_release_bes() status_t eng_release_bes()
{ {
/* setup BES control: disable scaler (b0 = 0) */ if (si->ps.card_arch < K8M800)
BESW(VID1_CTL, 0x00000000); {
/* setup BES control: disable scaler (b0 = 0) */
BESW(VID1_CTL, 0x00000000);
/* make sure the 'disable' command really gets executed: (no 'VBI' anymore if BES disabled) */ /* make sure the 'disable' command really gets executed: (no 'VBI' anymore if BES disabled) */
/* all registers are loaded immediately (b29 = 1), Vid1 cmds fire (b31 = 1) */ /* all registers are loaded immediately (b29 = 1), Vid1 cmds fire (b31 = 1) */
BESW(COMPOSE, 0xa0000000); BESW(COMPOSE, 0xa0000000);
}
else
{
/* setup BES control: disable scaler (b0 = 0) */
BESW(VID3_CTL, 0x00000000);
/* make sure the 'disable' command really gets executed: (no 'VBI' anymore if BES disabled) */
/* all registers are loaded immediately (b29 = 1), Vid3 cmds fire (b30 = 1) */
BESW(COMPOSE, 0x60000000);//fixme >>>!<<< test b29, should that be b27??
}
/* note that overlay is not in use (for eng_bes_move_overlay()) */ /* note that overlay is not in use (for eng_bes_move_overlay()) */
si->overlay.active = false; si->overlay.active = false;