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

📄 vid_inf.c

📁 IBM source for pallas/vulcan/vesta
💻 C
📖 第 1 页 / 共 2 页
字号:
/*----------------------------------------------------------------------------+|       This source code has been made available to you by IBM on an AS-IS|       basis.  Anyone receiving this source is licensed under IBM|       copyrights to use it in any way he or she deems fit, including|       copying it, modifying it, compiling it, and redistributing it either|       with or without modifications.  No license under IBM patents or|       patent applications is to be implied by the copyright license.||       Any user of this software should understand that IBM cannot provide|       technical support for this software and will not be responsible for|       any consequences resulting from the use of this software.||       Any person who transfers this source code or any derivative work|       must include the IBM copyright notice, this paragraph, and the|       preceding two paragraphs in the transferred software.||       COPYRIGHT   I B M   CORPORATION 1997, 1999, 2001|       LICENSED MATERIAL  -  PROGRAM PROPERTY OF I B M+----------------------------------------------------------------------------*//*----------------------------------------------------------------------------+| Author: Ling shao| File:   vid_inf.c| Purpose: video decoder interface layer PALLAS| Changes:| Date:         Comment:| -----         --------| 15-Oct-01     create                                                      SL| 30-April-03   Removed vid_osd_init() call from vid_init_module because it was|               not uninitialized in vid_cleanup_module and because it is called|               in vid_inf_open()| 10-Sep-03     Added MPEG_VID_ENABLE_DISP_14_9 and MPEG_VID_DISABLE_DISP_14_9+----------------------------------------------------------------------------*/#include <linux/kernel.h>       /* We're doing kernel work */#include <linux/module.h>       /* Specifically, a module */#include <linux/version.h>#include <linux/sched.h>#include <linux/ioport.h>#include <linux/mm.h>           /* for verify_area *//* The character device definitions are here */#include <linux/fs.h>#include <linux/devfs_fs_kernel.h>#include <asm/uaccess.h>        /* for get_user, copy_from_user */#include <os/os-interrupt.h>#include <os/drv_debug.h>#include "vid_osi.h"#include "vid_osi_scr.h"#include "vid_osd.h"#include <vid/vid_inf.h>extern VDEC _videoDecoder;#ifdef MODULEMODULE_PARM(_fmt, "i");MODULE_PARM_DESC(_fmt,                 "select default format: 0-NTSC, 1-PAL, 2-color bar on");#endifUINT    _denc_id = DENC_INTERNAL;UINT    _fmt = SCRMAN_FMT_NTSC;//INT vid_atom_verify_microcode(USHORT *pCode, INT nCount);int video_open_count = 0;//static int _open_count = 0;static int _mapped = 0;static int _src = -1;        //0: tv, 1: clip, -1: no sourcestatic int _still_p = 0;static int vid_inf_open(struct inode *inode, struct file *file){    /* We don't talk to two processes at the same time */    PDEBUG("open\n");//    if (_open_count != 0)    if (video_open_count != 0)    {        PDEBUG("VID: Driver in use\n");        return -EBUSY;    }    if(vid_osd_init() != 0)    {        PDEBUG("init osi layer error\n");    }    //vid_osd_reset_frame_buffer();//     _open_count++;     video_open_count++;        //vid_atom_reg_dump();    MOD_INC_USE_COUNT;    return 0;}static int vid_inf_release(struct inode *inode, struct file *file){    PDEBUG("close\n");        vid_osd_close();    //vid_osd_reset_frame_buffer();    //vid_atom_clear_framebuffer();//    _open_count--;    if(video_open_count != 0)       video_open_count--;                _src = -1;    //vid_atom_reg_dump();    MOD_DEC_USE_COUNT;    return 0;}static ssize_t vid_inf_read(struct file *file, char *buffer, /* The buffer to fill with the data                                                                 */                               size_t length,   /* The length of the buffer */                               loff_t * offset) /* offset to the file */{    //void* spb;    /* Number of bytes actually written to the buffer */    if(_still_p == 0)        return -1;    //copy still picture to the read buffer    /*if((spb = vid_osd_get_stillp_buf()) == NULL)        return -1;    copy_to_user(buffer, spb, length);    return length;*/        return length;}/* This function is called when somebody tries to * write into our device file. */static ssize_t vid_inf_write(struct file *file,                                const char *buffer,                                size_t length, loff_t * offset){    //added by shaol for stillp function    //if in still pic mode, other processes must wait    if(_still_p)    {         //interruptible_sleep_on(&WaitQ);        return -1;    }    return vid_osd_write(file, (void*)buffer, length);}static int vid_inf_mmap(struct file *file, struct vm_area_struct *vma){    int ret = -EINVAL;    unsigned long size;    //write clip buffer    if(vma->vm_flags & VM_WRITE)    {        PDEBUG("vid_inf_mmap: vma->vm_pgoff = %d \n", vma->vm_pgoff);        if(vma->vm_pgoff != 0)            return ret;        size = vma->vm_end - vma->vm_start;        PDEBUG("vid_inf_mmap: vma->vm_end = 0x%8.8x vma->vm_start = 0x%8.8x \n", vma->vm_end, vma->vm_start );        PDEBUG("mmap size = 0x%8.8lx vid_osd_get_clip_mem_size = 0x%8.8x \n", size,vid_osd_get_clip_mem_size());        if(size > vid_osd_get_clip_mem_size())            return ret;        ret = -EAGAIN;        vma->vm_page_prot.pgprot |= _PAGE_NO_CACHE;     // map without caching        if(remap_page_range(vma->vm_start, _videoDecoder.clipbuf.uAddr,                              size, vma->vm_page_prot))            return -EINVAL;        PDEBUG("vid_inf_mmap: _videoDecoder.clipbuf.uAddr = 0x%08x\n",_videoDecoder.clipbuf.uAddr);        _mapped = 1;        return 0;    }    return ret;}/* This function is called whenever a process tries to * do an ioctl on our device file. We get two extra * parameters (additional to the inode and file * structures, which all device functions get): the number * of the ioctl called and the parameter given to the * ioctl function. * * If the ioctl is write or read/write (meaning output * is returned to the calling process), the ioctl call * returns the output of this function. */static int vid_inf_ioctl(struct inode *inode,                     struct file *file,                     unsigned int ioctl_num,                     unsigned long ioctl_param) /* The parameter to it */{    int ret = 0;    switch (ioctl_num)    {        case MPEG_VID_STOP:            PDEBUG("VIDEO_STOP\n");            ret = vid_osi_stop(ioctl_param);            break;        case MPEG_VID_CONTINUE:        case MPEG_VID_PLAY:            PDEBUG("VIDEO_PLAY\n");            ret = vid_osi_play();            break;        case MPEG_VID_FREEZE:            PDEBUG("VIDEO_FREEZE\n");            ret = vid_osi_freeze();            break;        case MPEG_VID_SET_BLANK:            PDEBUG("VIDEO_SET_BLANK\n");            if (ioctl_param)                vid_osi_blank();            else                vid_osi_show();            break;        case MPEG_VID_SELECT_SOURCE:            ret = -1;            if(_src == -1)            {                //set source to tv                if(ioctl_param == 0)                {                    ret = vid_osi_init_tv();                    goto SetSource;                }                if(ioctl_param == 1)                {                    ret = vid_osd_init_clip();                    goto SetSource;                }            }            if(_src == 0)            {                if(ioctl_param == 0)                {                    ret = 0;                    goto SetSource;                }                if(ioctl_param == 1)                {                    vid_osi_close_tv();                    ret = vid_osd_init_clip();                    goto SetSource;                }            }            if(_src == 1)            {                if(ioctl_param == 1)                {                    ret = 0;                    goto SetSource;                }                if(ioctl_param == 0)                {                    vid_osi_close_clip();                    ret = vid_osi_init_tv();                    goto SetSource;                }            }SetSource:  if(ret == 0)                _src = ioctl_param;            break;        /*case MPEG_VID_GET_STATUS:            PDEBUG("VID_INF: VIDEO_GET_STATUS\n");            vid_get_status(pVDEC, (struct videoStatus *) ioctl_param);            break;*/                case MPEG_VID_PAUSE:                        PDEBUG("VIDEO PAUSED\n");                        ret = vid_osi_pause();                        break;                case MPEG_VID_FASTFORWARD:                        PDEBUG("FAST FORWARD\n");                        ret = vid_osi_fast_forward(ioctl_param);                        break;                case MPEG_VID_SLOWMOTION:                        PDEBUG("SLOW MOTION\n");                        ret = vid_osi_slow_motion(ioctl_param);                        break;        case MPEG_VID_GET_BUF_NOWAIT:            PDEBUG("GET BUF NOWAIT\n");            if(_mapped == 0)            {                PDEBUG("physical memory not mapped\n");                ret = -1;                break;            }            ret = vid_osd_get_buf_nowait((CLIPINFO*)ioctl_param);            break;        case MPEG_VID_GET_BUF_WAIT:            PDEBUG("GET BUF WAIT\n");            if(_mapped == 0)            {                PDEBUG("physical memory not mapped\n");                ret = -1;                break;            }            ret = vid_osd_get_buf_wait((CLIPINFO*)ioctl_param);            break;        case MPEG_VID_CLIP_WRITE:            PDEBUG("CLIP WRITE\n");            if(_mapped == 0)            {                PDEBUG("physical memory not mapped\n");                ret = -1;                break;            }            ret = vid_osd_clip_write((CLIPINFO*)ioctl_param);            break;        case MPEG_VID_END_OF_STREAM:

⌨️ 快捷键说明

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