MODULE_AUTHOR("Kitae KIM <kt920.kim@samsung.com");
MODULE_LICENSE("GPL2");
-#define DEVICE_NAME "newcodec"
+#define DEVICE_NAME "newcodec"
/* vendor, device value for PCI.*/
#define PCI_VENDOR_ID_TIZEN_EMUL 0xC9B5
#define PCI_DEVICE_ID_VIRTUAL_NEW_CODEC 0x1040
/* interrupt identifier for NEWCODEC */
-#define CODEC_IRQ_TASK 0x1f
+#define CODEC_IRQ_TASK 0x1f
//
-#define DEVICE_MEMORY_COUNT 8
-#define CODEC_CONTEXT_SIZE 1024
+#define DEVICE_MEMORY_COUNT 8
+#define CODEC_CONTEXT_SIZE 1024
// DEBUG
#ifndef CODEC_DEBUG
};
enum codec_api_index {
- CODEC_INIT = 0,
- CODEC_DECODE_VIDEO,
- CODEC_ENCODE_VIDEO,
- CODEC_DECODE_AUDIO,
- CODEC_ENCODE_AUDIO,
- CODEC_PICTURE_COPY,
- CODEC_DEINIT,
+ CODEC_INIT = 0,
+ CODEC_DECODE_VIDEO,
+ CODEC_ENCODE_VIDEO,
+ CODEC_DECODE_AUDIO,
+ CODEC_ENCODE_AUDIO,
+ CODEC_PICTURE_COPY,
+ CODEC_DEINIT,
};
struct device_mem {
static struct semaphore newcodec_buffer_mutex =
__SEMAPHORE_INITIALIZER(newcodec_buffer_mutex, DEVICE_MEMORY_COUNT);
-#define ENTER_CRITICAL_SECTION mutex_lock(&critical_section);
+#define ENTER_CRITICAL_SECTION mutex_lock(&critical_section);
#define LEAVE_CRITICAL_SECTION mutex_unlock(&critical_section);
#define CODEC_S_DEVICE_MEM_COUNT 63 // small (256K) 8M
static void unlock_buffer(void)
{
- up(&newcodec_buffer_mutex);
+ up(&newcodec_buffer_mutex);
// DEBUG("unlock buffer_mutex: %d\n", newcodec_buffer_mutex.count);
}
elem->occupied = false;
list_move_tail(&elem->entry, &newcodec->avail_s_memblk);
- up(&s_buffer_sema);
+ up(&s_buffer_sema);
DEBUG("unlock s_buffer_sema: %d\n", s_buffer_sema.count);
break;
struct device_mem *elem = NULL;
// decrease m_buffer_semaphore
- INFO("before down m_buffer_sema: %d\n", m_buffer_sema.count);
ret = down_interruptible(&m_buffer_sema);
- INFO("after down m_buffer_sema: %d\n", m_buffer_sema.count);
if (ret < 0) {
ERROR("m_buffer_sema: %d\n", m_buffer_sema.count);
ERROR("no available memory block\n");
elem->occupied = false;
list_move_tail(&elem->entry, &newcodec->avail_m_memblk);
- up(&m_buffer_sema);
- INFO("unlock m_buffer_sema: %d\n", m_buffer_sema.count);
-
+ up(&m_buffer_sema);
break;
}
}
elem->occupied = false;
list_move(&elem->entry, &newcodec->avail_l_memblk);
- up(&l_buffer_sema);
+ up(&l_buffer_sema);
DEBUG("up l_buffer_semaphore: %d\n", l_buffer_sema.count);
break;
secure_device_memory((uint32_t)file);
if (value < 0) {
ERROR("failed to get available memory\n");
- ret = -EINVAL;
+ ret = -EINVAL;
} else {
if (copy_to_user((void *)arg, &value, sizeof(uint32_t))) {
ERROR("ioctl: failed to copy data to user.\n");
if (copy_to_user((void *)arg, &newcodec->version, sizeof(int))) {
ERROR("ioctl: failed to copy data to user\n");
ret = -EIO;
- }
+ }
break;
case CODEC_CMD_GET_ELEMENT:
DEBUG("request a device to get codec elements\n");
} else if (copy_to_user((void *)arg, &value, sizeof(int))) {
ERROR("ioctl: failed to copy data to user\n");
ret = -EIO;
- }
+ }
break;
- case CODEC_CMD_SECURE_MEMORY:
+ case CODEC_CMD_SECURE_MEMORY:
value =
secure_device_memory((uint32_t)file);
if (value < 0) {
ret = -EIO;
}
}
- break;
- case CODEC_CMD_RELEASE_MEMORY:
- {
+ break;
+ case CODEC_CMD_RELEASE_MEMORY:
+ {
uint32_t mem_offset;
if (copy_from_user(&mem_offset, (void *)arg, sizeof(uint32_t))) {
break;
}
release_device_memory(mem_offset);
- }
- break;
- case CODEC_CMD_USE_DEVICE_MEM:
+ }
+ break;
+ case CODEC_CMD_USE_DEVICE_MEM:
{
uint32_t mem_offset;
}
}
break;
- case CODEC_CMD_S_SECURE_BUFFER:
+ case CODEC_CMD_S_SECURE_BUFFER:
value =
secure_s_device_memory((uint32_t)file);
if (value < 0) {
ret = -EIO;
}
}
- break;
- case CODEC_CMD_M_SECURE_BUFFER:
+ break;
+ case CODEC_CMD_M_SECURE_BUFFER:
value =
secure_m_device_memory((uint32_t)file);
if (value < 0) {
ret = -EIO;
}
}
- break;
- case CODEC_CMD_L_SECURE_BUFFER:
+ break;
+ case CODEC_CMD_L_SECURE_BUFFER:
value =
secure_l_device_memory((uint32_t)file);
if (value < 0) {
ret = -EIO;
}
}
- break;
+ break;
default:
DEBUG("no available command.");
ret = -EINVAL;
NEWCODEC_CURRENT_TIME
-// INFO("init context_flags[%d]: %d\n", ctx_index, context_flags[ctx_index]);
-
// wait_event_interruptible(wait_queue, context_flags[ctx_index] != 0);
// context_flags[ctx_index] = 0;
break;
// INFO("release small size of data\n");
release_s_device_memory(param->mem_offset);
}
-#if 0
- INFO("video ~ audio. context_flags[%d]: %d\n", ctx_index, context_flags[ctx_index]);
-#endif
wait_event_interruptible(wait_queue, context_flags[ctx_index] != 0);
context_flags[ctx_index] = 0;
break;
newcodec_write_data(CODEC_CMD_FILE_INDEX,
CODEC_CMD_CONTEXT_INDEX,
file_index, ctx_index);
- wait_event_interruptible(wait_queue, context_flags[ctx_index] != 0);
- context_flags[ctx_index] = 0;
+ wait_event_interruptible(wait_queue, context_flags[ctx_index] != 0);
+ context_flags[ctx_index] = 0;
break;
case CODEC_DEINIT:
newcodec_write_data(CODEC_CMD_FILE_INDEX,
if (copy_from_user(&ioparam, buf, sizeof(struct codec_param))) {
ERROR("failed to get codec parameter from user\n");
return -EIO;
- }
+ }
newcodec_func(&ioparam, (uint32_t)file);
if (copy_from_user(&ioparam, buf, sizeof(struct codec_param))) {
ERROR("failed to get codec parameter info from user\n");
return -EIO;
- }
+ }
DEBUG("enter %s. %p\n", __func__, file);
api_index = ioparam.api_index;
- ctx_index = ioparam.ctx_index;
+ ctx_index = ioparam.ctx_index;
switch (api_index) {
case CODEC_INIT:
// release_device_memory(ioparam.mem_offset);
DEBUG("context index: %d\n", ctx_index);
- wait_event_interruptible(wait_queue, context_flags[ctx_index] != 0);
+ wait_event_interruptible(wait_queue, context_flags[ctx_index] != 0);
DEBUG("wakeup. %d\n", ctx_index);
- context_flags[ctx_index] = 0;
+ context_flags[ctx_index] = 0;
}
break;
case CODEC_DECODE_VIDEO... CODEC_ENCODE_AUDIO:
// release_device_memory(ioparam.mem_offset);
- wait_event_interruptible(wait_queue, context_flags[ctx_index] != 0);
- context_flags[ctx_index] = 0;
+ wait_event_interruptible(wait_queue, context_flags[ctx_index] != 0);
+ context_flags[ctx_index] = 0;
}
break;
newcodec->ioaddr + CODEC_CMD_API_INDEX);
LEAVE_CRITICAL_SECTION;
- wait_event_interruptible(wait_queue, context_flags[ctx_index] != 0);
- context_flags[ctx_index] = 0;
+ wait_event_interruptible(wait_queue, context_flags[ctx_index] != 0);
+ context_flags[ctx_index] = 0;
}
break;