⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 av7110.c

📁 linux dvb的文件
💻 C
📖 第 1 页 / 共 5 页
字号:
                        iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);                        iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);                        iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);                        wake_up(&av7110->bmpq);                        break;                }                if (len>av7110->bmplen)                        len=av7110->bmplen;                if (len>2*1024)                        len=2*1024;                iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);                iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);                memcpy(av7110->debi_virt, av7110->bmpbuf+av7110->bmpp, len);                av7110->bmpp+=len;                av7110->bmplen-=len;                wait_for_debi_done(av7110);                saa7146_write(av7110->saa_mem, IER,                               saa7146_read(av7110->saa_mem, IER) | MASK_19 );                if (len<5) len=5; /* we want a real DEBI DMA */                iwdebi(av7110, DEBISWAB, DPRAM_BASE+txbuf, 0, (len+3)&~3);                spin_unlock(&av7110->debilock);                return;        case DATA_CI_GET:        case DATA_COMMON_INTERFACE:        case DATA_FSECTION:        case DATA_IPMPE:        case DATA_PIPING:                if (!len || len>4*1024) {                        iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);                        break;                }                  /* yes, fall through */        case DATA_TS_RECORD:        case DATA_PES_RECORD:                saa7146_write(av7110->saa_mem, IER,                               saa7146_read(av7110->saa_mem, IER) | MASK_19);                irdebi(av7110, DEBISWAB, DPRAM_BASE+rxbuf, 0, len);                spin_unlock(&av7110->debilock);                return;        case DATA_DEBUG_MESSAGE:                if (!len || len>0xff) {                        iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);                        break;                }                saa7146_write(av7110->saa_mem, IER,                               saa7146_read(av7110->saa_mem, IER) | MASK_19);                irdebi(av7110, DEBISWAB, Reserved, 0, len);                spin_unlock(&av7110->debilock);                return;        case DATA_IRCOMMAND:                 IR_handle(av7110,                           swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4)));                iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);                break;        default:                printk("gpioirq unknown type=%d len=%d\n",                        av7110->debitype, av7110->debilen);                break;        }              ARM_ClearMailBox(av7110);        av7110->debitype=-1;        spin_unlock(&av7110->debilock);        dprintk("GPIO0 irq exit 0\n");        }/**************************************************************************** * DEBI command polling  ****************************************************************************/static int OutCommand(av7110_t *av7110, u16* buf, int length){        int i;        u32 start;#ifdef COM_DEBUG        u32 stat;#endif        if (!av7110->arm_ready)                return -1;        start = jiffies;        while ( rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2 ) )        {                ddelay(1);                if ((jiffies - start) > ARM_WAIT_FREE) {                        printk(KERN_ERR "%s: timeout waiting for COMMAND idle\n", __FUNCTION__);                        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__);                        return -1;                }        }#endif        start = jiffies;        while ( rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2) & OSDQFull )        {                ddelay(1);                if ((jiffies - start) > ARM_WAIT_OSD)                {                        printk(KERN_ERR "%s: timeout waiting for !OSDQFull\n", __FUNCTION__);                        return -1;                }        }        for (i=2; i<length; i++)                wdebi(av7110, DEBINOSWAP, COMMAND + 2*i, (u32) buf[i], 2);        if (length)                wdebi(av7110, DEBINOSWAP, COMMAND + 2, (u32) buf[1], 2);        else                wdebi(av7110, DEBINOSWAP, COMMAND + 2, 0, 2);        wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2);#ifdef COM_DEBUG        start = jiffies;        while ( rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2 ) )        {                ddelay(1);                if ((jiffies - start) > ARM_WAIT_FREE) {                        printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__);                        return -1;                }        }	stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);	if (stat & GPMQOver) {		printk(KERN_ERR "%s: GPMQOver\n", __FUNCTION__);		return -1;	}	else if (stat & OSDQOver) {		printk(KERN_ERR "%s: OSDQOver\n", __FUNCTION__);		return -1;	}#endif        return 0;}inline static int SOutCommand(av7110_t *av7110, u16* buf, int length){        int ret;                if (!av7110->arm_ready)                return -1;        if (down_interruptible(&av7110->dcomlock))		return -ERESTARTSYS;        ret=OutCommand(av7110, buf, length);        up(&av7110->dcomlock);	if (ret)                printk("SOutCommand error\n");        return ret;}static int outcom(av7110_t *av7110, int type, int com, int num, ...){	va_list args;        u16 buf[num+2];        int i, ret;        buf[0]=(( type << 8 ) | com);        buf[1]=num;        if (num) {                va_start(args, num);                for (i=0; i<num; i++)                        buf[i+2]=va_arg(args, u32);                va_end(args);        }        ret = SOutCommand(av7110, buf, num+2);	if (ret)                printk("outcom error\n");	return ret;}int SendCICommand(av7110_t *av7110, u8 subcom, u8 *Params, u8 ParamLen){        int i, ret;        u16 CommandBuffer[18] = { ((COMTYPE_COMMON_IF << 8) + subcom),                                  16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };        	for(i=0; (i<ParamLen)&&(i<32); i++)		{		if(i%2 == 0)			CommandBuffer[(i/2)+2] = (u16)(Params[i]) << 8;		else			CommandBuffer[(i/2)+2] |= Params[i];	}        ret = SOutCommand(av7110, CommandBuffer, 18);	if (ret)                printk("SendCICommand error\n");	return ret;}static int CommandRequest(av7110_t *av7110, u16 *Buff, int length, u16 *buf, int n){	int err;        s16 i;        u32 start;#ifdef COM_DEBUG        u32 stat;#endif        if (!av7110->arm_ready)                return -1;        if (down_interruptible(&av7110->dcomlock))		return -ERESTARTSYS;        if ((err = OutCommand(av7110, Buff, length)) < 0) {		up(&av7110->dcomlock);		printk("CommandRequest error\n");		return err;	}        start = jiffies;        while ( rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) )         {#ifdef _NOHANDSHAKE                ddelay(1);#endif                if ((jiffies - start) > ARM_WAIT_FREE) {                        printk("%s: timeout waiting for COMMAND to complete\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#ifdef COM_DEBUG	stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);	if (stat & GPMQOver) {		printk(KERN_ERR "%s: GPMQOver\n", __FUNCTION__);                up(&av7110->dcomlock);		return -1;	}	else if (stat & OSDQOver) {		printk(KERN_ERR "%s: OSDQOver\n", __FUNCTION__);                up(&av7110->dcomlock);		return -1;	}#endif        for (i=0; i<n; i++)                buf[i] = rdebi(av7110, DEBINOSWAP, COM_BUFF + 2*i, 0, 2);	up(&av7110->dcomlock);        return 0;}static inline int RequestParameter(av7110_t *av7110, u16 tag, u16* Buff, s16 length){	int ret;        ret = CommandRequest(av7110, &tag, 0, Buff, length);	if (ret)		printk("RequestParameter error\n");	return ret;}/**************************************************************************** * Firmware commands  ****************************************************************************/inline static int SendDAC(av7110_t *av7110, u8 addr, u8 data){        return outcom(av7110, COMTYPE_AUDIODAC, AudioDAC, 2, addr, data);}static intSetVolume(av7110_t *av7110, int volleft, int volright){        int err=0;	int chleft, chright;                switch (av7110->adac_type) {        case DVB_ADAC_TI:                chleft=(volleft*256)/946;                chright=(volright*256)/946;                if (chleft > 0x45)                        chleft=0x45;                if (chright > 0x45)                        chright=0x45;                err=SendDAC(av7110, 3, 0x80 + chleft);                if (err)                        return err;                err=SendDAC(av7110, 4, chright);		break;                        case DVB_ADAC_CRYSTAL:                chleft=127-volleft/2;                chright=127-volright/2;                i2c_writereg(av7110, 0x20, 0x03, chleft);                i2c_writereg(av7110, 0x20, 0x04, chright);		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;                }        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -