/*---------------------------------------------------------------------------- *Function: CMM_Open *Parameters: InitHandle :Handle to JPEG context dwAccess : dwShareMode :File share mode of JPEG *Return Value: This function returns a handle that identifies the open context of JPEG to the calling application. *Implementation Notes: Opens JPEG CODEC device for reading, writing, or both -----------------------------------------------------------------------------*/ DWORD CMM_Open( DWORD InitHandle, DWORD dwAccess, DWORD dwShareMode ) { CODEC_MEM_CTX *CodecMem; DWORD ret; UINT8 inst_no; ret = LockCMMMutex(); if(!ret){ RETAILMSG(1, (TEXT("[CMM_Open] CMM Mutex Lock Fail\r\n"))); return FALSE; } // check the number of instance if((inst_no = GetInstanceNo()) < 0){ RETAILMSG(1, (TEXT("[CMM_Open] Instance Number error-too many instance\r\n"))); UnlockCMMMutex(); return FALSE; } CodecMem = (CODEC_MEM_CTX *)malloc(sizeof(CODEC_MEM_CTX)); if(CodecMem == NULL){ RETAILMSG(1, (TEXT("[CMM_Init] CodecMem allocatopn failed\r\n"))); UnlockCMMMutex(); return FALSE; } memset(CodecMem, 0x00, sizeof(CODEC_MEM_CTX)); CodecMem->inst_no = inst_no; printD("\n*****************************\n[CMM_Open] instanceNo : %d\n*****************************\n", CodecMem->inst_no); PrintList(); UnlockCMMMutex(); return (DWORD)CodecMem; }
static int s3c_cmm_open(struct inode *inode, struct file *file) { CODEC_MEM_CTX *CodecMem; int ret; int inst_no; ret = LockCMMMutex(); if (!ret){ LOG_MSG(LOG_ERROR, "s3c_cmm_open", "DD::CMM Mutex Lock Fail\n"); return -1; } // check the number of instance if((inst_no = GetInstanceNo()) < 0){ LOG_MSG(LOG_ERROR, "s3c_cmm_open", "Instance Number error-too many instance\r\n"); UnlockCMMMutex(); return -1; } CodecMem = (CODEC_MEM_CTX *)kmalloc(sizeof(CODEC_MEM_CTX), GFP_KERNEL); if(CodecMem == NULL){ LOG_MSG(LOG_ERROR, "s3c_cmm_open", "CodecMem application failed\n"); UnlockCMMMutex(); return -1; } memset(CodecMem, 0x00, sizeof(CODEC_MEM_CTX)); CodecMem->inst_no = inst_no; printk("\n*****************************\n[CMM_Open] instanceNo : %d\n*****************************\n", CodecMem->inst_no); PrintList(); file->private_data = (CODEC_MEM_CTX *)CodecMem; UnlockCMMMutex(); return 0; }