Example #1
0
static TVC_STATUS _AllocateInternalSRAM(void)
{
    UINT32 pfhDmaFifoSize = TVC_SRC_WIDTH_MAX * 2 * TVC_PFH_DMA_FIFO_LEN;
    UINT32 reszWorkingMemSize = ((TVC_TAR_WIDTH_MAX + 3) / 4 * 4) * 2 * TVC_RSZ_WORK_MEM_SZ;

    _tvcContext.pfhDmaBufPA = 
        MT6573_SYSRAM_ALLOC(MT6573SYSRAMUSR_TVC,
                            pfhDmaFifoSize + reszWorkingMemSize, 16);

    if (0 == _tvcContext.pfhDmaBufPA) {
        printk("[TVC][ERROR] allocate TVC internal SRAM failed\n");
        return TVC_STATUS_ERROR;
    }

    _tvcContext.reszLineBufPA = _tvcContext.pfhDmaBufPA + pfhDmaFifoSize;
    
    ASSERT((_tvcContext.pfhDmaBufPA & 0xF) == 0);
    ASSERT((_tvcContext.reszLineBufPA & 0x7) == 0);

    return TVC_STATUS_OK;
}
Example #2
0
//--------------------------------------------------------------------------
// JPEG DECODER IOCTRL FUNCTION
//--------------------------------------------------------------------------
static int jpeg_dec_ioctl(unsigned int cmd, unsigned long arg, struct file *file)
{
    int retValue;
    unsigned int decResult, i;
    long timeout_jiff;
    JPEG_DEC_DRV_IN inParams;
    JPEG_DEC_DRV_OUT outParams;

    unsigned int *pStatus;
    
    pStatus = (unsigned int*)file->private_data;

    if(NULL == pStatus)
    {
        printk("Private data is null in flush operation. HOW COULD THIS HAPPEN ??\n");
        return -EFAULT;
    }
    
    switch(cmd)
    {
        case JPEG_DEC_IOCTL_INIT:
            JPEG_MSG("JPEG Decoder Initial and Lock\n");

            retValue = jpeg_drv_dec_init();
            if(retValue != 0)
            {
                return -EBUSY;   
            }  

            dec_src_va = 0;
            dec_src_pa = 0;
            table_buffer_va = 0;
            table_buffer_pa = 0;

            *pStatus = JPEG_DEC_PROCESS;
            
            break;
            
        case JPEG_DEC_IOCTL_CONFIG:
            JPEG_MSG("JPEG Decoder Configure Hardware\n");

            if(*pStatus != JPEG_DEC_PROCESS)
            {
                printk("Permission Denied! This process can not access decoder");
                return -EFAULT;
            }

            if(dec_status == 0)
            {
                printk("Decoder status is available, HOW COULD THIS HAPPEN ??");
                *pStatus = 0;
                return -EFAULT;
            }
            // copy input parameters
            if(copy_from_user(&inParams, (void *)arg, sizeof(JPEG_DEC_DRV_IN)))
            {
                printk("JPEG Decoder : Copy from user error\n");
                return -EFAULT;
            }

            JPEG_MSG("JPEG Decoder src addr : 0x%x\n", inParams.srcStreamAddr);
            JPEG_MSG("JPEG Decoder src Size : %d\n", inParams.srcStreamSize); 
            JPEG_MSG("JPEG Decoder src format : %d\n", inParams.samplingFormat);
            JPEG_MSG("JPEG Decoder mcu row : %d\n", inParams.mcuRow);
            JPEG_MSG("JPEG Decoder mcu column : %d\n", inParams.mcuColumn);
            
            dec_src_size = inParams.srcStreamSize;
            //now_size = inParams.srcStreamSize;

            dec_src_va = 0;
            dec_src_pa = inParams.srcStreamAddr;
                       
            // 0. reset    
            jpeg_drv_dec_reset();

            // 1. set source address
            jpeg_drv_dec_set_file_buffer(dec_src_pa , dec_src_size);

            // 2. set table address
#ifdef USE_SYSRAM
            //table_buffer_pa = alloc_internal_sram(INTERNAL_SRAM_JPEG_DECODER, 4096, 2048);
            table_buffer_pa = MT6573_SYSRAM_ALLOC(MT6573SYSRAMUSR_JPGDECODER, TABLE_SIZE, 2048);
#else
            table_buffer_va = dma_alloc_coherent(0, TABLE_SIZE, &table_buffer_pa, GFP_KERNEL);
#endif

            if(table_buffer_pa == 0)
            {
                printk("JPEG Decoder : table pa == 0!!!\n");
                return -EFAULT;
            }
            jpeg_drv_dec_set_table_address(table_buffer_pa);

            // 3. set sampling factor
            if(1 != jpeg_drv_dec_set_sampling_factor_related(inParams.samplingFormat))
            {
                printk("JPEG Decoder : Sampling Factor Unsupported!!!\n");
                return -EFAULT;
            }

            // 4. set component id
            if(inParams.componentNum == 1)
            {
                jpeg_drv_dec_set_component_id(inParams.componentID[0], 0, 0);
            }
            else
            {
                jpeg_drv_dec_set_component_id(inParams.componentID[0], inParams.componentID[1], inParams.componentID[2]);
            }
            
            // 5. set tatal mcu number
            jpeg_drv_dec_set_total_mcu(inParams.mcuRow * inParams.mcuColumn);

            // set mcu number per row
            //jpeg_drv_dec_set_mcu_per_row();

            // 6. set each DU
            for(i = 0 ; i < inParams.componentNum ; i++)
            {
                jpeg_drv_dec_set_du(i, inParams.totalDU[i], inParams.dummyDU[i], inParams.duPerMCURow[i]);
            }
            
            // 7. set file size
            jpeg_drv_dec_set_file_size(dec_src_size + 16);

            // 8. set Q-table id
            if(inParams.componentNum == 1)
            {
                jpeg_drv_dec_set_q_table_id(inParams.qTableSelector[0], 0, 0);
            }
            else
            {
                jpeg_drv_dec_set_q_table_id(inParams.qTableSelector[0], inParams.qTableSelector[1], inParams.qTableSelector[2]);
            }

            break;
        
        case JPEG_DEC_IOCTL_START:
            // copy input parameters
            JPEG_MSG("JPEG Decoder : JPEG_DEC_IOCTL_START\n");

            if(*pStatus != JPEG_DEC_PROCESS)
            {
                printk("Permission Denied! This process can not access decoder");
                return -EFAULT;
            }
            if(dec_status == 0)
            {
                printk("Decoder status is available, HOW COULD THIS HAPPEN ??");
                *pStatus = 0;
                return -EFAULT;
            }
//            jpeg_reg_dump();
            jpeg_drv_dec_start();

            return 0;
            
            
        case JPEG_DEC_IOCTL_WAIT:
            if(*pStatus != JPEG_DEC_PROCESS)
            {
                printk("Permission Denied! This process can not access decoder");
                return -EFAULT;
            }
            if(dec_status == 0)
            {
                printk("Decoder status is available, HOW COULD THIS HAPPEN ??");
                *pStatus = 0;
                return -EFAULT;
            }           
            if(copy_from_user(&outParams, (void *)arg, sizeof(JPEG_DEC_DRV_OUT)))
            {
                printk("JPEG Decoder : Copy from user error\n");
                return -EFAULT;
            }

            //set timeout
            timeout_jiff = outParams.timeout* HZ / 1000;
            JPEG_MSG("JPEG Decoder Time Jiffies : %ld\n", timeout_jiff);   
            wait_event_interruptible_timeout(dec_wait_queue, _jpeg_dec_int_status, timeout_jiff);
            
            decResult = jpeg_drv_dec_get_result();
            _jpeg_dec_int_status = 0;

#ifdef USE_SYSRAM 
            if(table_buffer_pa != 0)
            {
                MT6573_SYSRAM_FREE(MT6573SYSRAMUSR_JPGDECODER);
                table_buffer_pa = 0;
            }
#else        
            if(table_buffer_va != 0)
            {
                dma_free_coherent(0, TABLE_SIZE, table_buffer_va, table_buffer_pa);
                table_buffer_va = 0;
            }
#endif

            JPEG_MSG("Decode Result : %d \n", decResult);
            if(decResult != 0)
            {
                jpeg_reg_dump();
            }
            if(copy_to_user(outParams.result, &decResult, sizeof(unsigned int)))
            {
                printk("JPEG Decoder : Copy to user error (result)\n");
                return -EFAULT;            
            }
            break;
            
        case JPEG_DEC_IOCTL_DEINIT:
            // copy input parameters
            if(*pStatus != JPEG_DEC_PROCESS)
            {
                printk("Permission Denied! This process can not access decoder");
                return -EFAULT;
            }
            if(dec_status == 0)
            {
                printk("Decoder status is available, HOW COULD THIS HAPPEN ??");
                *pStatus = 0;
                return -EFAULT;
            }
            jpeg_drv_dec_deinit();
            *pStatus = 0;
            
            break;
    }
    return 0;
}