📄 av7110.c
字号:
break; default: err = -1; } if(!err) { av7110->audiostate.mixer_state.volume_left = volleft; av7110->audiostate.mixer_state.volume_right = volright; } return err;}#ifdef CONFIG_DVB_AV7110_OSDinline static int ResetBlend(av7110_t *av7110, u8 windownr){ return outcom(av7110, COMTYPE_OSD, SetNonBlend, 1, windownr);}inline static int SetColorBlend(av7110_t *av7110, u8 windownr){ return outcom(av7110, COMTYPE_OSD, SetCBlend, 1, windownr); }inline static int SetWindowBlend(av7110_t *av7110, u8 windownr, u8 blending){ return outcom(av7110, COMTYPE_OSD, SetWBlend, 2, windownr, blending); }inline static int SetBlend_(av7110_t *av7110, u8 windownr, OSDPALTYPE colordepth, u16 index, u8 blending){ return outcom(av7110, COMTYPE_OSD, SetBlend, 4, windownr, colordepth, index, blending);} inline static int SetColor_(av7110_t *av7110, u8 windownr, OSDPALTYPE colordepth, u16 index, u16 colorhi, u16 colorlo){ return outcom(av7110, COMTYPE_OSD, SetColor, 5, windownr, colordepth, index, colorhi, colorlo);} inline static int BringToTop(av7110_t *av7110, u8 windownr){ return outcom(av7110, COMTYPE_OSD, WTop, 1, windownr);} inline static int SetFont(av7110_t *av7110, u8 windownr, u8 fontsize, u16 colorfg, u16 colorbg){ return outcom(av7110, COMTYPE_OSD, Set_Font, 4, windownr, fontsize, colorfg, colorbg);} static int FlushText(av7110_t *av7110){ u32 start; if (down_interruptible(&av7110->dcomlock)) return -ERESTARTSYS; start = jiffies; while ( rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2 ) ) { ddelay(1); if ((jiffies - start) > ARM_WAIT_OSD) { printk(KERN_ERR "%s: timeout waiting for BUFF1_BASE == 0\n", __FUNCTION__); up(&av7110->dcomlock); return -1; } } up(&av7110->dcomlock); return 0;}static int WriteText(av7110_t *av7110, u8 win, u16 x, u16 y, u8* buf){ int i, ret; u32 start; int length=strlen(buf)+1; u16 cbuf[5] = { (COMTYPE_OSD<<8) + DText, 3, win, x, y }; if (down_interruptible(&av7110->dcomlock)) return -ERESTARTSYS; start = jiffies; while ( rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2 ) ) { ddelay(1); if ((jiffies - start) > ARM_WAIT_OSD) { printk(KERN_ERR "%s: timeout waiting for BUFF1_BASE == 0\n", __FUNCTION__); up(&av7110->dcomlock); return -1; } }#ifndef _NOHANDSHAKE start = jiffies; while ( rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2 ) ) { ddelay(1); if ((jiffies - start) > ARM_WAIT_SHAKE) { printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__); up(&av7110->dcomlock); return -1; } }#endif for (i=0; i<length/2; i++) wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i*2, swab16(*(u16 *)(buf+2*i)), 2); if (length&1) wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i*2, 0, 2); ret=OutCommand(av7110, cbuf, 5); up(&av7110->dcomlock); if (ret) printk("WriteText error\n"); return ret;}inline static int DrawLine(av7110_t *av7110, u8 windownr, u16 x, u16 y, u16 dx, u16 dy, u16 color){ return outcom(av7110, COMTYPE_OSD, DLine, 6, windownr, x, y, dx, dy, color);} inline static int DrawBlock(av7110_t *av7110, u8 windownr, u16 x, u16 y, u16 dx, u16 dy, u16 color){ return outcom(av7110, COMTYPE_OSD, DBox, 6, windownr, x, y, dx, dy, color);} inline static int HideWindow(av7110_t *av7110, u8 windownr){ return outcom(av7110, COMTYPE_OSD, WHide, 1, windownr);} inline static int MoveWindowRel(av7110_t *av7110, u8 windownr, u16 x, u16 y){ return outcom(av7110, COMTYPE_OSD, WMoveD, 3, windownr, x, y);} inline static int MoveWindowAbs(av7110_t *av7110, u8 windownr, u16 x, u16 y){ return outcom(av7110, COMTYPE_OSD, WMoveA, 3, windownr, x, y);} inline static int DestroyOSDWindow(av7110_t *av7110, u8 windownr){ return outcom(av7110, COMTYPE_OSD, WDestroy, 1, windownr);} #if 0static void DestroyOSDWindows(av7110_t *av7110){ int i; for (i=1; i<7; i++) outcom(av7110, COMTYPE_OSD, WDestroy, 1, i);} #endifstatic inline int CreateOSDWindow(av7110_t *av7110, u8 windownr, DISPTYPE disptype, u16 width, u16 height){ return outcom(av7110, COMTYPE_OSD, WCreate, 4, windownr, disptype, width, height);} static OSDPALTYPE bpp2pal[8]={Pal1Bit, Pal2Bit, 0, Pal4Bit, 0, 0, 0, Pal8Bit}; static DISPTYPE bpp2bit[8]={BITMAP1, BITMAP2, 0, BITMAP4, 0, 0, 0, BITMAP8}; static inline int LoadBitmap(av7110_t *av7110, u16 format, u16 dx, u16 dy, int inc, u8* data){ int bpp; int i; int d, delta; u8 c; DECLARE_WAITQUEUE(wait, current); if (av7110->bmp_state==BMP_LOADING) { add_wait_queue(&av7110->bmpq, &wait); while (1) { set_current_state(TASK_INTERRUPTIBLE); if (av7110->bmp_state!=BMP_LOADING || signal_pending(current)) break; schedule(); } current->state=TASK_RUNNING; remove_wait_queue(&av7110->bmpq, &wait); } if (av7110->bmp_state==BMP_LOADING) return -1; av7110->bmp_state=BMP_LOADING; if (format==BITMAP8) { bpp=8; delta = 1; } else if (format==BITMAP4) { bpp=4; delta = 2; } else if (format==BITMAP2) { bpp=2; delta = 4; } else if (format==BITMAP1) { bpp=1; delta = 8; } else { av7110->bmp_state=BMP_NONE; return -1; } av7110->bmplen= ((dx*dy*bpp+7)&~7)/8; av7110->bmpp=0; if (av7110->bmplen>32768) { av7110->bmp_state=BMP_NONE; return -1; } for (i=0; i<dy; i++) { if (copy_from_user(av7110->bmpbuf+1024+i*dx, data+i*inc, dx)) { av7110->bmp_state=BMP_NONE; return -1; } } if (format != BITMAP8) { for (i=0; i<dx*dy/delta; i++) { c = ((u8 *)av7110->bmpbuf)[1024+i*delta+delta-1]; for (d=delta-2; d>=0; d--) { c |= (((u8 *)av7110->bmpbuf)[1024+i*delta+d] << ((delta-d-1)*bpp)); ((u8 *)av7110->bmpbuf)[1024+i] = c; } } } av7110->bmplen+=1024; return outcom(av7110, COMTYPE_OSD, LoadBmp, 3, format, dx, dy);} static int BlitBitmap(av7110_t *av7110, u16 win, u16 x, u16 y, u16 trans){ DECLARE_WAITQUEUE(wait, current); if (av7110->bmp_state==BMP_NONE) return -1; if (av7110->bmp_state==BMP_LOADING) { add_wait_queue(&av7110->bmpq, &wait); while (1) { set_current_state(TASK_INTERRUPTIBLE); if (av7110->bmp_state!=BMP_LOADING || signal_pending(current)) break; schedule(); } current->state=TASK_RUNNING; remove_wait_queue(&av7110->bmpq, &wait); } if (av7110->bmp_state==BMP_LOADED) return outcom(av7110, COMTYPE_OSD, BlitBmp, 4, win, x, y, trans); return -1;} static inline int ReleaseBitmap(av7110_t *av7110){ if (av7110->bmp_state!=BMP_LOADED) return -1; av7110->bmp_state=BMP_NONE; return outcom(av7110, COMTYPE_OSD, ReleaseBmp, 0);} static u32 RGB2YUV(u16 R, u16 G, u16 B){ u16 y, u, v; u16 Y, Cr, Cb; y = R * 77 + G * 150 + B * 29; // Luma=0.299R+0.587G+0.114B 0..65535 u = 2048+B * 8 -(y>>5); // Cr 0..4095 v = 2048+R * 8 -(y>>5); // Cb 0..4095 Y=y/256; Cb=u/16; Cr=v/16; return Cr|(Cb<<16)|(Y<<8);}static voidOSDSetColor(av7110_t *av7110, u8 color, u8 r, u8 g, u8 b, u8 blend){ u16 ch, cl; u32 yuv; yuv=blend ? RGB2YUV(r,g,b) : 0; cl=(yuv&0xffff); ch=((yuv>>16)&0xffff); SetColor_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], color, ch, cl); SetBlend_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], color, ((blend>>4)&0x0f));}static intOSDSetPalette(av7110_t *av7110, u32 *colors, u8 first, u8 last){ int i; int length = last - first + 1; if (length * 4 > DATA_BUFF3_SIZE) return -1; for (i=0; i<length; i++) { u32 blend = (colors[i] & 0xF0000000) >> 4; u32 yuv = blend ? RGB2YUV(colors[i] & 0xFF, (colors[i] >> 8) & 0xFF, (colors[i] >> 16) & 0xFF) | blend : 0; yuv = ((yuv & 0xFFFF0000) >> 16) | ((yuv & 0x0000FFFF) << 16); // TODO kls2003-06-15: not sure if this is endian-proof wdebi(av7110, DEBINOSWAP, DATA_BUFF3_BASE + i*4, yuv, 4); } return outcom(av7110, COMTYPE_OSD, Set_Palette, 4, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], first, last);}static intOSDSetBlock(av7110_t *av7110, int x0, int y0, int x1, int y1, int inc, u8 *data){ uint w, h, bpp, bpl, size, lpb, bnum, brest; int i; w=x1-x0+1; h=y1-y0+1; if (inc<=0) inc=w; if (w<=0 || w>720 || h<=0 || h>576) return -1; bpp=av7110->osdbpp[av7110->osdwin]+1; bpl=((w*bpp+7)&~7)/8; size=h*bpl; lpb=(32*1024)/bpl; bnum=size/(lpb*bpl); brest=size-bnum*lpb*bpl; for (i=0; i<bnum; i++) { LoadBitmap(av7110, bpp2bit[av7110->osdbpp[av7110->osdwin]], w, lpb, inc, data); BlitBitmap(av7110, av7110->osdwin, x0, y0+i*lpb, 0); data+=lpb*inc; } if (brest) { LoadBitmap(av7110, bpp2bit[av7110->osdbpp[av7110->osdwin]], w, brest/bpl, inc, data); BlitBitmap(av7110, av7110->osdwin, x0, y0+bnum*lpb, 0); } ReleaseBitmap(av7110); return 0;}static int OSD_DrawCommand(av7110_t *av7110, osd_cmd_t *dc){ switch (dc->cmd) { case OSD_Close: DestroyOSDWindow(av7110, av7110->osdwin); return 0; case OSD_Open: av7110->osdbpp[av7110->osdwin]=(dc->color-1)&7; CreateOSDWindow(av7110, av7110->osdwin, bpp2bit[av7110->osdbpp[av7110->osdwin]], dc->x1-dc->x0+1, dc->y1-dc->y0+1); if (!dc->data) { MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); SetColorBlend(av7110, av7110->osdwin); } return 0; case OSD_Show: MoveWindowRel(av7110, av7110->osdwin, 0, 0); return 0; case OSD_Hide: HideWindow(av7110, av7110->osdwin); return 0; case OSD_Clear: DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, 0); return 0; case OSD_Fill: DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, dc->color); return 0; case OSD_SetColor: OSDSetColor(av7110, dc->color, dc->x0, dc->y0, dc->x1, dc->y1); return 0; case OSD_SetPalette: { if (FW_VERSION(av7110->arm_app) >= 0x2618) OSDSetPalette(av7110, (u32 *)dc->data, dc->color, dc->x0); else { int i, len=dc->x0-dc->color+1; u8 *colors=(u8 *)dc->data; for (i=0; i<len; i++) OSDSetColor(av7110, dc->color+i, colors[i*4] , colors[i*4+1], colors[i*4+2], colors[i*4+3]); } return 0; } case OSD_SetTrans: return 0; case OSD_SetPixel: DrawLine(av7110, av7110->osdwin, dc->x0, dc->y0, 0, 0, dc->color); return 0; case OSD_GetPixel: return 0; case OSD_SetRow: dc->y1=dc->y0; case OSD_SetBlock: OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data); return 0; case OSD_FillRow: DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0, dc->x1-dc->x0+1, dc->y1, dc->color); return 0; case OSD_FillBlock: DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0, dc->x1-dc->x0+1, dc->y1-dc->y0+1, dc->color); return 0; case OSD_Line: DrawLine(av7110, av7
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -