aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprasanth <prasanth.kamuju@linaro.org>2014-06-11 15:41:11 +0530
committerprasanth <prasanth.kamuju@linaro.org>2014-06-11 16:20:15 +0530
commit1cc851ddf64c48967d4fd1a10ce329b0d0edca12 (patch)
treea41116f9c2b3064be5cf5a5b3abfc403c6bac62b
parent2b678aa9688593247bc484bde4841a459732c7c8 (diff)
downloadvpb-1cc851ddf64c48967d4fd1a10ce329b0d0edca12.tar.gz
Test app Compilation fixes and
ION supported functionality added.
-rw-r--r--Makefile13
-rw-r--r--decoder_driver_test.c555
-rw-r--r--decoder_driver_test.h19
-rw-r--r--msm_ion.h2
-rw-r--r--msm_vidc_dec.h18
5 files changed, 318 insertions, 289 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..a8e9e82
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,13 @@
+all: Vidctest
+Vidctest: queue.o message_queue.o decoder_driver_test.o
+ arm-linux-gnueabihf-gcc -pthread queue.o message_queue.o decoder_driver_test.o -o Vidctest
+queue.o:
+ arm-linux-gnueabihf-gcc -c queue.c
+message_queue.o:
+ arm-linux-gnueabihf-gcc -c message_queue.c
+decoder_driver_test.o:
+ arm-linux-gnueabihf-gcc -c decoder_driver_test.c
+
+clean:
+ -rm -f *.o
+ -rm -f Vidctest
diff --git a/decoder_driver_test.c b/decoder_driver_test.c
index 1998acc..50eee3d 100644
--- a/decoder_driver_test.c
+++ b/decoder_driver_test.c
@@ -39,6 +39,7 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/************************************************************************/
/* STATIC VARIABLES */
/************************************************************************/
+#define MEM_HEAP_ID ION_CP_MM_HEAP_ID
static int Code_type;
static int total_frames = 0;
@@ -62,10 +63,11 @@ static unsigned clp2(unsigned x)
x = x | (x >>16);
return x + 1;
}
-
static void* video_thread (void *);
static void* async_thread (void *);
+int m_vdec_ion_devicefd;
+/* Control starts from here */
int main (int argc, char **argv)
{
struct video_decoder_context *decoder_context = NULL;
@@ -75,16 +77,7 @@ int main (int argc, char **argv)
int error = 1;
unsigned int i = 0;
- file_name = argv [1];
- file_ptr = fopen (file_name,"rb");
-
- if (file_ptr == NULL)
- {
- DEBUG_PRINT("\n File is not located ");
- return -1;
- }
-
-
+ /* Allocate memory for the decode context */
decoder_context = (struct video_decoder_context *) \
calloc (sizeof (struct video_decoder_context),1);
if (decoder_context == NULL)
@@ -94,9 +87,19 @@ int main (int argc, char **argv)
decoder_context->outputBufferFile = NULL;
decoder_context->inputBufferFile = NULL;
decoder_context->video_driver_fd = -1;
+
+ /* Open input file and store in decode context */
+ file_name = argv [1];
+ file_ptr = fopen (file_name,"rb");
+ if (file_ptr == NULL)
+ {
+ DEBUG_PRINT("\n File is not located ");
+ return -1;
+ }
decoder_context->inputBufferFile = file_ptr;
- file_ptr = fopen ("/data/output.yuv","wb");
+ /*Open output file and store in decode context*/
+ file_ptr = fopen ("output.yuv","wb");
if (file_ptr == NULL)
{
DEBUG_PRINT("\n File can't be created");
@@ -105,77 +108,46 @@ int main (int argc, char **argv)
}
decoder_context->outputBufferFile = file_ptr;
- switch (atoi(argv[2]))
- {
- case 0:
- DEBUG_PRINT("\n MPEG4 codec selected");
- decoder_context->decoder_format = VDEC_CODECTYPE_MPEG4;
- Code_type = 0;
- break;
- case 1:
- DEBUG_PRINT("\n H.263");
- decoder_context->decoder_format = VDEC_CODECTYPE_H263;
- Code_type = 0;
- break;
- case 2:
- DEBUG_PRINT("\n H.264");
- decoder_context->decoder_format = VDEC_CODECTYPE_H264;
- Code_type = 1;
- break;
- default:
- DEBUG_PRINT("\n Wrong codec type");
- error = -1;
- break;
- }
+ /* Open ion drive for memory allocations */
+ m_vdec_ion_devicefd = open ("/dev/ion", O_RDONLY);
- if (error != -1)
- {
- temp1 = atoi(argv[3]);
- temp2 = atoi(argv[4]);
+ if (m_vdec_ion_devicefd < 0) {
+ DEBUG_PRINT("\nERROR: ION Device open() Failed -------- ");
+ return -1;
+ }
- if (((temp1%16) != 0) || ((temp2%16) != 0))
- {
- error = -1;
- }
- else
- {
- decoder_context->video_resoultion.frame_height = temp1;
- decoder_context->video_resoultion.frame_width = temp2;
- }
- }
+ /*As of now decoder type,frame_height and frame_width are hardcoded */
+ decoder_context->decoder_format = VDEC_CODECTYPE_MPEG4;
+ Code_type = 0;
+ decoder_context->video_resoultion.frame_height = 480;
+ decoder_context->video_resoultion.frame_width = 640;
- switch (atoi(argv[5]))
- {
- case 0:
- DEBUG_PRINT("\n No Sink");
- decoder_context->outputBufferFile = NULL;
- break;
- }
+
+ /* All the inputs are all right now, start the decode */
if ( error != -1 && (init_decoder (decoder_context) == -1 ))
{
DEBUG_PRINT("\n Init decoder fails ");
error = -1;
}
- DEBUG_PRINT("\n Decoder open successfull");
+ DEBUG_PRINT("\n Decoder Initialized successfull");
/*Allocate input and output buffers*/
- if (error != -1 && (allocate_buffer (VDEC_BUFFER_TYPE_INPUT,
+ if (error != -1 && (ion_allocate_buffer(VDEC_BUFFER_TYPE_INPUT,
decoder_context)== -1))
{
DEBUG_PRINT("\n Error in input Buffer allocation");
error = -1;
}
- if (error != -1 && (allocate_buffer (VDEC_BUFFER_TYPE_OUTPUT,
+ if (error != -1 && (ion_allocate_buffer(VDEC_BUFFER_TYPE_OUTPUT,
decoder_context)== -1))
{
DEBUG_PRINT("\n Error in output Buffer allocation");
error = -1;
}
-
if (error != -1 && (start_decoding (decoder_context) == -1))
{
DEBUG_PRINT("\n Error in start decoding call");
@@ -188,28 +160,29 @@ int main (int argc, char **argv)
error = -1;
}
- DEBUG_PRINT("\n De-init the decoder");
- if ((deinit_decoder (decoder_context) == -1))
+ if (error != -1)
{
- error = -1;
- }
-
+ DEBUG_PRINT ("\n\n >>>>> Total Number of frames decoded %d\n",total_frames);
- (void)free_buffer (VDEC_BUFFER_TYPE_INPUT,decoder_context);
- (void)free_buffer (VDEC_BUFFER_TYPE_OUTPUT,decoder_context);
+ /* Decoding is completed,now we need to de-initialize the decoder */
+ DEBUG_PRINT("\n De-init the decoder Enter");
+ if ((deinit_decoder (decoder_context) == -1))
+ {
+ error = -1;
+ }
- if (decoder_context->inputBufferFile != NULL)
- {
- fclose (decoder_context->inputBufferFile);
- }
- if (decoder_context->outputBufferFile != NULL)
- {
- fclose (decoder_context->outputBufferFile);
+ (void)free_buffer (VDEC_BUFFER_TYPE_INPUT,decoder_context);
+ (void)free_buffer (VDEC_BUFFER_TYPE_OUTPUT,decoder_context);
+ if (decoder_context->inputBufferFile != NULL)
+ {
+ fclose (decoder_context->inputBufferFile);
+ }
+ if (decoder_context->outputBufferFile != NULL)
+ {
+ fclose (decoder_context->outputBufferFile);
+ }
+ free(decoder_context);
}
- DEBUG_PRINT ("\n Total Number of frames decoded %d",total_frames);
- DEBUG_PRINT("\n closing the driver");
- free (decoder_context);
-
return error;
}
@@ -217,16 +190,16 @@ int init_decoder ( struct video_decoder_context *init_decode )
{
struct vdec_ioctl_msg ioctl_msg = {NULL,NULL};
struct video_queue_context *queue_ptr = NULL;
-#ifdef MAX_RES_720P
- enum vdec_output_fromat output_format = VDEC_YUV_FORMAT_NV12;
-#endif
-#ifdef MAX_RES_1080P
+//#ifdef MAX_RES_720P
+// enum vdec_output_fromat output_format = VDEC_YUV_FORMAT_NV12;
+//#endif
+//#ifdef MAX_RES_1080P
enum vdec_output_fromat output_format = VDEC_YUV_FORMAT_TILE_4x2;
-#endif
+//#endif
pthread_mutexattr_t init_values;
- DEBUG_PRINT("\n Before calling the open");
+ DEBUG_PRINT("\n Before calling the open and the output_format is : 0x%x ", output_format);
init_decode->video_driver_fd = open ("/dev/msm_vidc_dec", \
O_RDWR | O_NONBLOCK);
@@ -235,7 +208,7 @@ int init_decoder ( struct video_decoder_context *init_decode )
if (init_decode->video_driver_fd < 0)
{
- DEBUG_PRINT("\n Open failed");
+ DEBUG_PRINT("\n /dev/msm_vidc_dev Open failed");
return -1;
}
@@ -251,6 +224,11 @@ int init_decoder ( struct video_decoder_context *init_decode )
return -1;
}
+ if(ioctl(init_decode->video_driver_fd,VDEC_IOCTL_SET_CONT_ON_RECONFIG) < 0)
+ {
+ DEBUG_PRINT("\n ========== VDEC_IOCTL_SET_CONT_ON_RECONFIG FAILED....");
+ }
+
/*Set the output format*/
ioctl_msg.in = &output_format;
ioctl_msg.out = NULL;
@@ -275,7 +253,6 @@ int init_decoder ( struct video_decoder_context *init_decode )
DEBUG_PRINT("\n Query Input bufffer requirements");
/*Get the Buffer requirements for input and output ports*/
-
init_decode->input_buffer.buffer_type = VDEC_BUFFER_TYPE_INPUT;
ioctl_msg.in = NULL;
ioctl_msg.out = &init_decode->input_buffer;
@@ -287,10 +264,14 @@ int init_decoder ( struct video_decoder_context *init_decode )
return -1;
}
- DEBUG_PRINT("\n input Size=%d min count =%d actual count = %d", \
+ DEBUG_PRINT("\n input Size=%d min count =%d actual count = %d, maxcount = %d,alignment = %d,buf_poolid= %ld,meta_buffer_size=%d",\
init_decode->input_buffer.buffer_size,\
init_decode->input_buffer.mincount,\
- init_decode->input_buffer.actualcount);
+ init_decode->input_buffer.actualcount,\
+ init_decode->input_buffer.maxcount,\
+ init_decode->input_buffer.alignment,\
+ init_decode->input_buffer.buf_poolid,\
+ init_decode->input_buffer.meta_buffer_size);
init_decode->input_buffer.buffer_type = VDEC_BUFFER_TYPE_INPUT;
@@ -318,10 +299,14 @@ int init_decoder ( struct video_decoder_context *init_decode )
return -1;
}
- DEBUG_PRINT("\n output Size=%d min count =%d actual count = %d", \
+ DEBUG_PRINT("\n output_buffer Size=%d min count =%d actual count = %d, maxcount = %d,alignment = %d,buf_poolid= %ld,meta_buffer_size=%d",\
init_decode->output_buffer.buffer_size,\
init_decode->output_buffer.mincount,\
- init_decode->output_buffer.actualcount);
+ init_decode->output_buffer.actualcount,\
+ init_decode->output_buffer.maxcount,\
+ init_decode->output_buffer.alignment,\
+ init_decode->output_buffer.buf_poolid,\
+ init_decode->output_buffer.meta_buffer_size);
/*Create Queue related data structures*/
queue_ptr = &init_decode->queue_context;
@@ -370,7 +355,7 @@ int free_buffer ( enum vdec_buffer buffer_dir,
)
{
unsigned int buffercount = 0,i=0;
- struct vdec_bufferpayload **ptemp = NULL;
+ struct vdec_bufferpayload *ptemp = NULL;
if (decode_context == NULL)
{
@@ -384,16 +369,11 @@ int free_buffer ( enum vdec_buffer buffer_dir,
for (i=0;i<buffercount;i++)
{
- if (ptemp [i])
- {
- if (ptemp [i]->pmem_fd != -1)
+ if (ptemp [i].pmem_fd != -1)
{
- munmap ( ptemp [i]->bufferaddr,ptemp [i]->mmaped_size);
- ptemp [i]->bufferaddr = NULL;
- close (ptemp [i]->pmem_fd);
- }
- free (ptemp [i]);
- ptemp [i] = NULL;
+ munmap ( ptemp [i].bufferaddr,ptemp [i].mmaped_size);
+ ptemp [i].bufferaddr = NULL;
+ close (ptemp [i].pmem_fd);
}
}
free (decode_context->ptr_inputbuffer);
@@ -402,18 +382,10 @@ int free_buffer ( enum vdec_buffer buffer_dir,
else if ( buffer_dir == VDEC_BUFFER_TYPE_OUTPUT )
{
buffercount = decode_context->output_buffer.actualcount;
- ptemp = decode_context->ptr_outputbuffer;
+ ptemp = (struct vdec_bufferpayload*)&decode_context->ptr_outputbuffer;
- if (decode_context->ptr_respbuffer)
+ if (decode_context->ptr_respbuffer)
{
- for (i=0;i<buffercount;i++)
- {
- if (decode_context->ptr_respbuffer [i])
- {
- free (decode_context->ptr_respbuffer[i]);
- decode_context->ptr_respbuffer [i] = NULL;
- }
- }
free (decode_context->ptr_respbuffer);
decode_context->ptr_respbuffer = NULL;
}
@@ -422,17 +394,12 @@ int free_buffer ( enum vdec_buffer buffer_dir,
{
for (i=0;i<buffercount;i++)
{
- if (ptemp [i])
- {
- if (ptemp [i]->pmem_fd != -1)
+ if (ptemp [i].pmem_fd != -1)
{
- munmap ( ptemp [i]->bufferaddr,ptemp [i]->mmaped_size);
- ptemp [i]->bufferaddr = NULL;
- close (ptemp [i]->pmem_fd);
+ munmap ( ptemp [i].bufferaddr,ptemp [i].mmaped_size);
+ ptemp [i].bufferaddr = NULL;
+ close (ptemp [i].pmem_fd);
}
- free (ptemp [i]);
- ptemp [i] = NULL;
- }
}
free (ptemp);
decode_context->ptr_outputbuffer = NULL;
@@ -442,7 +409,7 @@ int free_buffer ( enum vdec_buffer buffer_dir,
return 1;
}
-int allocate_buffer ( enum vdec_buffer buffer_dir,
+int ion_allocate_buffer ( enum vdec_buffer buffer_dir,
struct video_decoder_context *decode_context
)
{
@@ -451,6 +418,14 @@ int allocate_buffer ( enum vdec_buffer buffer_dir,
struct vdec_ioctl_msg ioctl_msg = {NULL,NULL};
unsigned int buffercount = 0,i=0,alignedsize=0;
unsigned int buffersize = 0;
+ struct ion_allocation_data *alloc_data;
+// struct ion_fd_data *fd_data;
+ int rc = -1;
+ int fd = -1;
+ int pmem_fd = -1;
+ unsigned char *buf_addr = NULL;
+ int ii;
+// struct enc_ion ion_data;
if ( decode_context == NULL)
{
@@ -467,136 +442,180 @@ int allocate_buffer ( enum vdec_buffer buffer_dir,
return -1;
}
- buffercount = decode_context->input_buffer.actualcount;
- alignedsize = decode_context->input_buffer.alignment;
- buffersize = decode_context->input_buffer.buffer_size;
- buffersize = (buffersize + alignedsize) & (~alignedsize);
- }
- else if (buffer_dir == VDEC_BUFFER_TYPE_OUTPUT)
- {
- /*Check if buffers are allocated*/
- if (decode_context->ptr_outputbuffer != NULL)
- {
- DEBUG_PRINT ("\nallocate_buffer: Double allcoate output");
- return -1;
- }
-
- buffercount = decode_context->output_buffer.actualcount;
- alignedsize = decode_context->output_buffer.alignment;
- buffersize = decode_context->output_buffer.buffer_size;
- buffersize = (buffersize + alignedsize) & (~alignedsize);
-
- decode_context->ptr_respbuffer = (struct vdec_output_frameinfo **)\
- calloc (sizeof (struct vdec_output_frameinfo *),buffercount);
+ DEBUG_PRINT("\n Allocate i/p buffer Header: Cnt(%d) Sz(%d) \n",
+ decode_context->input_buffer.actualcount,decode_context->input_buffer.buffer_size);
- if (decode_context->ptr_respbuffer == NULL)
- {
- DEBUG_PRINT ("\n Allocate failure ptr_respbuffer");
- return -1;
- }
+ decode_context->ptr_inputbuffer = (struct vdec_bufferpayload *) \
+ calloc ((sizeof (struct vdec_bufferpayload)),decode_context->input_buffer.actualcount);
+ if (decode_context->ptr_inputbuffer == NULL)
+ {
+ DEBUG_PRINT("\n ptr_inputbuffer allocated FAIL ---\n");
+ return -1;
+ }
+ decode_context->ip_buf_ion_info = (struct vdec_ion *) \
+ calloc ((sizeof (struct vdec_ion)),decode_context->input_buffer.actualcount);
- for (i=0; i< buffercount; i++)
- {
- decode_context->ptr_respbuffer [i] = (struct vdec_output_frameinfo *)\
- calloc (sizeof (struct vdec_output_frameinfo),buffercount);
- if (decode_context->ptr_respbuffer [i] == NULL)
+ if (decode_context->ip_buf_ion_info == NULL)
{
- DEBUG_PRINT ("\nfailed to allocate vdec_output_frameinfo");
+ DEBUG_PRINT("\n ip_buf_ion_info allocated FAIL ---\n");
return -1;
}
- }
- }
- else
- {
- DEBUG_PRINT ("\nallocate_buffer: Wrong buffer directions");
- return -1;
- }
-
- ptemp = (struct vdec_bufferpayload **)\
- calloc (sizeof (struct vdec_bufferpayload *),buffercount);
-
- if (ptemp == NULL)
- {
- DEBUG_PRINT ("\nallocate_buffer: vdec_bufferpayload failure");
- return -1;
- }
-
-
- if (buffer_dir == VDEC_BUFFER_TYPE_OUTPUT)
- {
- DEBUG_PRINT ("\nallocate_buffer: OUT");
- decode_context->ptr_outputbuffer = ptemp;
- }
- else
- {
- DEBUG_PRINT ("\nallocate_buffer: IN");
- decode_context->ptr_inputbuffer = ptemp;
- }
-
- /*Allocate buffer headers*/
- for (i=0; i< buffercount; i++)
- {
- ptemp [i] = (struct vdec_bufferpayload*)\
- calloc (sizeof (struct vdec_bufferpayload),1);
-
- if (ptemp [i] == NULL)
- {
- DEBUG_PRINT ("\nallocate_buffer: ptemp [i] calloc failure");
- return -1;
- }
-
- if (buffer_dir == VDEC_BUFFER_TYPE_OUTPUT)
- {
- decode_context->ptr_respbuffer [i]->client_data = \
- (void *) ptemp [i];
- }
- ptemp [i]->pmem_fd = -1;
-
- }
+ for (i=0; i < decode_context->input_buffer.actualcount; i++)
+ {
+ decode_context->ptr_inputbuffer [i].pmem_fd = -1;
+ decode_context->ip_buf_ion_info[i].ion_device_fd = -1;
+ }
- for (i=0; i< buffercount; i++)
+ for(i=0;i < decode_context->input_buffer.actualcount; i++)
+ {
+ struct ion_allocation_data *alloc_data = &decode_context->ip_buf_ion_info[i].ion_alloc_data;
+ struct ion_fd_data *fd_data = &decode_context->ip_buf_ion_info[i].fd_ion_data;
+ fd = m_vdec_ion_devicefd;
+ alloc_data->len = decode_context->input_buffer.buffer_size;
+ alloc_data->flags = 0x1;
+ alloc_data->align = 2048;
+ alloc_data->heap_mask = 0x2000000;
+
+ rc = ioctl(fd,ION_IOC_ALLOC,alloc_data);
+ if (rc || !alloc_data->handle) {
+ DEBUG_PRINT("\n ION ALLOC failed, fd = %d, rc = %d, handle = 0x%p, "
+ "errno ", fd, rc, alloc_data->handle);
+ alloc_data->handle = NULL;
+ return -1;
+ }
+ DEBUG_PRINT("ION memory allocated successfully \n");
+ fd_data->handle = alloc_data->handle;
+ rc = ioctl(fd,ION_IOC_MAP,fd_data);
+ if (rc) {
+ DEBUG_PRINT("\n ION MAP failed, fd = %d, handle = 0x%p, errno =",
+ fd, fd_data->handle);
+ fd_data->fd = -1;
+ return -1;
+ }
+
+ decode_context->ip_buf_ion_info[i].ion_device_fd = fd;
+ pmem_fd = decode_context->ip_buf_ion_info[i].fd_ion_data.fd;
+ buf_addr = (unsigned char *)mmap(NULL,
+ decode_context->input_buffer.buffer_size,
+ PROT_READ|PROT_WRITE, MAP_SHARED, pmem_fd, 0);
+ if (buf_addr == MAP_FAILED)
+ {
+ pmem_fd = -1;
+ DEBUG_PRINT("\n Map Failed to allocate input buffer");
+ return -1;
+ }
+ decode_context->ptr_inputbuffer [i].bufferaddr = buf_addr;
+ decode_context->ptr_inputbuffer [i].pmem_fd = pmem_fd;
+ decode_context->ptr_inputbuffer [i].buffer_len = decode_context->input_buffer.buffer_size;
+ decode_context->ptr_inputbuffer [i].mmaped_size = decode_context->input_buffer.buffer_size;
+ decode_context->ptr_inputbuffer [i].offset = 0;
+
+ setbuffers.buffer_type = VDEC_BUFFER_TYPE_INPUT;
+ memcpy (&setbuffers.buffer,&decode_context->ptr_inputbuffer [i],sizeof(struct vdec_bufferpayload));
+ ioctl_msg.in = &setbuffers;
+ ioctl_msg.out = NULL;
+
+ if (ioctl (decode_context->video_driver_fd,VDEC_IOCTL_SET_BUFFER,
+ &ioctl_msg) < 0)
+ {
+ DEBUG_PRINT("\n Set Buffers Failed");
+ return -1;
+ }
+ DEBUG_PRINT("\ninput ion_alloc: buf_addr = 0x%x, len = %d, size = %d, \n",\
+ buf_addr,decode_context->input_buffer.buffer_size,decode_context->input_buffer.buffer_size);
+ } /* for loop*/
+ DEBUG_PRINT ("\nInput buffers ion_allocate_buffer: Success");
+ } /* VDEC_BUFFER_TYPE_INPUT */
+ if( buffer_dir == VDEC_BUFFER_TYPE_OUTPUT )
{
- ptemp [i]->pmem_fd = open ("/dev/pmem_adsp",O_RDWR);
-
- if (ptemp [i]->pmem_fd < 0)
- {
- DEBUG_PRINT ("\nallocate_buffer: open pmem_adsp failed");
- return -1;
- }
+ DEBUG_PRINT("\n\nAllocate o/p buffer Header: Cnt(%d) Sz(%d)",
+ decode_context->output_buffer.actualcount,
+ decode_context->output_buffer.buffer_size);
- ptemp [i]->bufferaddr = mmap(NULL,clp2(buffersize),PROT_READ|PROT_WRITE,
- MAP_SHARED,ptemp [i]->pmem_fd,0);
- DEBUG_PRINT ("\n pmem fd = %d virt addr = %p",ptemp [i]->pmem_fd,\
- ptemp [i]->bufferaddr);
- if (ptemp [i]->bufferaddr == MAP_FAILED)
- {
- ptemp [i]->bufferaddr = NULL;
- DEBUG_PRINT ("\nallocate_buffer: MMAP failed");
- return -1;
- }
- ptemp [i]->buffer_len = buffersize;
- ptemp [i]->mmaped_size = clp2 (buffersize);
+ decode_context-> ptr_outputbuffer = (struct vdec_bufferpayload *)\
+ calloc (sizeof(struct vdec_bufferpayload),
+ decode_context->output_buffer.actualcount);
- setbuffers.buffer_type = buffer_dir;
- memcpy (&setbuffers.buffer,ptemp [i],sizeof (struct vdec_bufferpayload));
+ decode_context->ptr_respbuffer = (struct vdec_output_frameinfo *)\
+ calloc (sizeof (struct vdec_output_frameinfo),
+ decode_context->output_buffer.actualcount);
- ioctl_msg.in = &setbuffers;
- ioctl_msg.out = NULL;
+ decode_context->op_buf_ion_info = (struct vdec_ion *)\
+ calloc (sizeof(struct vdec_ion),
+ decode_context->output_buffer.actualcount);
- if (ioctl (decode_context->video_driver_fd,VDEC_IOCTL_SET_BUFFER,
- &ioctl_msg) < 0)
+ for(i=0; i < decode_context->output_buffer.actualcount ; i++)
+ {
+ decode_context->ptr_outputbuffer[i].pmem_fd = -1;
+ decode_context->op_buf_ion_info[i].ion_device_fd =-1;
+ /*Create a mapping between buffers*/
+ decode_context->ptr_respbuffer[i].client_data = (void *)\
+ &decode_context->ptr_outputbuffer[i];
+ }
+ for (i=0; i< decode_context->output_buffer.actualcount; i++)
{
- DEBUG_PRINT ("\nallocate_buffer: Set Buffer IOCTL failed");
- return -1;
- }
-
- }
- DEBUG_PRINT ("\nallocate_buffer: Success");
+ struct ion_allocation_data *alloc_data = &decode_context->op_buf_ion_info[i].ion_alloc_data;
+ struct ion_fd_data *fd_data = &decode_context->op_buf_ion_info[i].fd_ion_data;
+ fd = m_vdec_ion_devicefd;
+ alloc_data->len = decode_context->output_buffer.buffer_size;
+ alloc_data->flags = 0x1;
+ alloc_data->align = 8192;
+ alloc_data->heap_mask = 0x2000000;
+ rc = ioctl(fd,ION_IOC_ALLOC,alloc_data);
+
+ if (rc || !alloc_data->handle) {
+ DEBUG_PRINT("\n ION ALLOC failed, fd = %d, rc = %d, handle = 0x%p, "
+ "errno ", fd, rc, alloc_data->handle);
+ alloc_data->handle = NULL;
+ return -1;
+ }
+ fd_data->handle = alloc_data->handle;
+ rc = ioctl(fd,ION_IOC_MAP,fd_data);
+ if (rc) {
+ DEBUG_PRINT("\n ION MAP failed, fd = %d, handle = 0x%p, errno",
+ fd, fd_data->handle);
+ fd_data->fd = -1;
+ return -1;
+ }
+
+ decode_context->op_buf_ion_info[i].ion_device_fd = fd;
+ pmem_fd = decode_context->op_buf_ion_info[i].fd_ion_data.fd;
+ buf_addr = (unsigned char *)mmap(NULL,
+ decode_context->output_buffer.buffer_size,
+ PROT_READ|PROT_WRITE, MAP_SHARED, pmem_fd, 0);
+ if (buf_addr == MAP_FAILED)
+ {
+ pmem_fd = -1;
+ DEBUG_PRINT("\n Map Failed to allocate input buffer");
+ return -1;
+ }
+ decode_context->ptr_outputbuffer [i].bufferaddr = buf_addr;
+ decode_context->ptr_outputbuffer [i].pmem_fd = pmem_fd;
+ decode_context->ptr_outputbuffer [i].buffer_len = decode_context->output_buffer.buffer_size;
+ decode_context->ptr_outputbuffer [i].mmaped_size = decode_context->output_buffer.buffer_size;
+ decode_context->ptr_outputbuffer [i].offset = 0;
+
+ setbuffers.buffer_type = VDEC_BUFFER_TYPE_OUTPUT;
+ memcpy (&setbuffers.buffer,&decode_context->ptr_outputbuffer [i],sizeof(struct vdec_bufferpayload));
+ ioctl_msg.in = &setbuffers;
+ ioctl_msg.out = NULL;
+
+ if (ioctl (decode_context->video_driver_fd,VDEC_IOCTL_SET_BUFFER,
+ &ioctl_msg) < 0)
+ {
+ DEBUG_PRINT("\n Set Buffers Failed");
+ return -1;
+ }
+ DEBUG_PRINT("\noutput ion_alloc: buf_addr = 0x%x, len = %d, size = %d, \n",\
+ buf_addr,decode_context->output_buffer.buffer_size,decode_context->output_buffer.buffer_size);
+
+ } /* for loop */
+ DEBUG_PRINT ("\nprasanth --------- output ion_allocate_buffer: Success");
+ } /* VDEC_BUFFER_TYPE_OUTPUT */
return 1;
}
-
int start_decoding (struct video_decoder_context *decode_context)
{
struct vdec_ioctl_msg ioctl_msg = {NULL,NULL};
@@ -629,15 +648,15 @@ int start_decoding (struct video_decoder_context *decode_context)
while (i < decode_context->output_buffer.mincount)
{
fillbuffer.buffer.buffer_len =
- decode_context->ptr_outputbuffer [i]->buffer_len;
+ decode_context->ptr_outputbuffer [i].buffer_len;
fillbuffer.buffer.bufferaddr =
- decode_context->ptr_outputbuffer [i]->bufferaddr;
+ decode_context->ptr_outputbuffer [i].bufferaddr;
fillbuffer.buffer.offset =
- decode_context->ptr_outputbuffer [i]->offset;
+ decode_context->ptr_outputbuffer [i].offset;
fillbuffer.buffer.pmem_fd =
- decode_context->ptr_outputbuffer [i]->pmem_fd;
- fillbuffer.client_data = (void *)decode_context->ptr_respbuffer [i];
- DEBUG_PRINT ("\n Client Data on output = %p",fillbuffer.client_data);
+ decode_context->ptr_outputbuffer [i].pmem_fd;
+ fillbuffer.client_data = (void *)&decode_context->ptr_respbuffer[i];
+ DEBUG_PRINT ("\n Client Data on output = %p and bufferaddr = %p",fillbuffer.client_data,decode_context->ptr_outputbuffer [i].bufferaddr);
ioctl_msg.in = &fillbuffer;
ioctl_msg.out = NULL;
@@ -655,9 +674,8 @@ int start_decoding (struct video_decoder_context *decode_context)
i = 0;
while (i < decode_context->input_buffer.mincount)
{
- DEBUG_PRINT("\n Read Frame from File");
- data_len = read_frame ( decode_context->ptr_inputbuffer [i]->bufferaddr,
- decode_context->ptr_inputbuffer [i]->buffer_len,
+ data_len = read_frame ( decode_context->ptr_inputbuffer [i].bufferaddr,
+ decode_context->ptr_inputbuffer [i].buffer_len,
decode_context->inputBufferFile);
if (data_len == 0)
{
@@ -666,17 +684,16 @@ int start_decoding (struct video_decoder_context *decode_context)
}
DEBUG_PRINT("\n Read Frame from File szie = %u",data_len);
frameinfo.bufferaddr =
- decode_context->ptr_inputbuffer [i]->bufferaddr;
+ decode_context->ptr_inputbuffer [i].bufferaddr;
frameinfo.offset = 0;
- frameinfo.pmem_fd = decode_context->ptr_inputbuffer [i]->pmem_fd;
- frameinfo.pmem_offset = decode_context->ptr_inputbuffer [i]->offset;
+ frameinfo.pmem_fd = decode_context->ptr_inputbuffer [i].pmem_fd;
+ frameinfo.pmem_offset = decode_context->ptr_inputbuffer [i].offset;
frameinfo.datalen = data_len;
- frameinfo.client_data = (struct vdec_bufferpayload *)\
- decode_context->ptr_inputbuffer [i];
+ frameinfo.client_data = (struct vdec_bufferpayload *)&decode_context->ptr_inputbuffer [i];
/*TODO: Time stamp needs to be updated*/
ioctl_msg.in = &frameinfo;
ioctl_msg.out = NULL;
-
+ DEBUG_PRINT ("\n input frame Client Data address = %p",frameinfo.client_data);
if (ioctl (decode_context->video_driver_fd,VDEC_IOCTL_DECODE_FRAME,
&ioctl_msg) < 0)
{
@@ -756,25 +773,22 @@ int deinit_decoder (struct video_decoder_context *init_decode)
{
close (init_decode->video_driver_fd);
}
-
if (init_decode->queue_context.ptr_cmdq)
{
free (init_decode->queue_context.ptr_cmdq);
init_decode->queue_context.ptr_cmdq = NULL;
}
-
if (init_decode->queue_context.ptr_dataq)
{
free (init_decode->queue_context.ptr_dataq);
init_decode->queue_context.ptr_dataq = NULL;
}
-
sem_destroy (&init_decode->queue_context.sem_message);
sem_destroy (&init_decode->sem_synchronize);
pthread_mutex_destroy(&init_decode->queue_context.mutex);
pthread_mutex_destroy (&read_lock);
-
+ DEBUG_PRINT("\n all threads are closed");
return 1;
}
@@ -835,6 +849,7 @@ static void* video_thread (void *context)
sem_post (&decode_context->sem_synchronize);
break;
}
+ DEBUG_PRINT("\n buffaddr in INPUT_BUF_DONE : %p",tempbuffer->bufferaddr);
data_len = read_frame ( tempbuffer->bufferaddr,
tempbuffer->buffer_len,
decode_context->inputBufferFile
@@ -864,15 +879,15 @@ static void* video_thread (void *context)
DEBUG_PRINT("\n Decoder frame failed");
sem_post (&decode_context->sem_synchronize);
}
+
DEBUG_PRINT("\n Input buffer done send next buffer current value = %d",\
total_frames);
break;
-
+// case VDEC_MSG_EVT_CONFIG_CHANGED:
case VDEC_MSG_RESP_OUTPUT_BUFFER_DONE:
-
outputbuffer = (struct vdec_output_frameinfo *)\
queueitem->clientdata;
- DEBUG_PRINT("\n Value of client Data in VT %p",queueitem->clientdata);
+ DEBUG_PRINT("\n OUTPUT_BUFFER_DONE and send the same to FILL: %p",outputbuffer->bufferaddr);
if (outputbuffer == NULL || outputbuffer->bufferaddr == NULL ||
outputbuffer->client_data == NULL
)
@@ -907,11 +922,6 @@ static void* video_thread (void *context)
tempbuffer = (struct vdec_bufferpayload *)\
outputbuffer->client_data;
- DEBUG_PRINT("\n recieved output buffer consume outbuffer");
- DEBUG_PRINT("\nValues outputbuffer->bufferaddr = %p",\
- outputbuffer->bufferaddr);
- DEBUG_PRINT ("\n Vir address of allocated buffer %p",\
- tempbuffer->bufferaddr);
fillbuffer.buffer.buffer_len = tempbuffer->buffer_len;
fillbuffer.buffer.bufferaddr = tempbuffer->bufferaddr;
fillbuffer.buffer.offset = tempbuffer->offset;
@@ -939,6 +949,8 @@ static void* video_thread (void *context)
DEBUG_PRINT("\n Flush output complete");
sem_post (&decode_context->sem_synchronize);
break;
+ default :
+ DEBUG_PRINT("\n Video thread default case:: \n");
}
if (queueitem->cmd == VDEC_MSG_RESP_STOP_DONE)
@@ -977,9 +989,6 @@ static void* async_thread (void *context)
ioctl_msg.in = NULL;
ioctl_msg.out = (void*)&vdec_msg;
- DEBUG_PRINT ("\n Sizeof vdec_msginfo = %d ",sizeof (vdec_msg));
- DEBUG_PRINT("\n Address of Vdec msg in async thread %p",\
- ioctl_msg.out);
if (ioctl (decode_context->video_driver_fd,VDEC_IOCTL_GET_NEXT_MSG,\
(void*)&ioctl_msg) < 0)
{
@@ -987,6 +996,7 @@ static void* async_thread (void *context)
}
else
{
+ DEBUG_PRINT("\n\nioctl read next msg code : %d",vdec_msg.msgcode);
switch (vdec_msg.msgcode)
{
case VDEC_MSG_RESP_FLUSH_INPUT_DONE:
@@ -994,7 +1004,6 @@ static void* async_thread (void *context)
case VDEC_MSG_RESP_START_DONE:
case VDEC_MSG_RESP_STOP_DONE:
case VDEC_MSG_EVT_HW_ERROR:
- DEBUG_PRINT("\nioctl read next msg");
queueitem.cmd = vdec_msg.msgcode;
queueitem.status = vdec_msg.status_code;
queueitem.clientdata = NULL;
@@ -1007,6 +1016,7 @@ static void* async_thread (void *context)
queueitem.status = vdec_msg.status_code;
queueitem.clientdata = (void *)\
vdec_msg.msgdata.input_frame_clientdata;
+ DEBUG_PRINT("\n ----------------------- ioctl INPUT_BUFFER_DONE ");
break;
case VDEC_MSG_RESP_OUTPUT_FLUSHED:
@@ -1015,8 +1025,6 @@ static void* async_thread (void *context)
queueitem.status = vdec_msg.status_code;
outputframe = (struct vdec_output_frameinfo *)\
vdec_msg.msgdata.output_frame.client_data;
- DEBUG_PRINT ("\n Client Data value in %p", \
- vdec_msg.msgdata.output_frame.client_data);
outputframe->bufferaddr = vdec_msg.msgdata.output_frame.bufferaddr;
outputframe->framesize.bottom = \
vdec_msg.msgdata.output_frame.framesize.bottom;
@@ -1030,9 +1038,8 @@ static void* async_thread (void *context)
outputframe->len = vdec_msg.msgdata.output_frame.len;
outputframe->time_stamp = vdec_msg.msgdata.output_frame.time_stamp;
queueitem.clientdata = (void *)outputframe;
- DEBUG_PRINT ("\n Client Data value Copy %p",queueitem.clientdata);
+ DEBUG_PRINT ("\n ********************* ioctl OUTPUT_BUFFER_DONE Client Data value Copy %p",queueitem.clientdata);
break;
-
default:
DEBUG_PRINT("\nIn Default of get next message %d",vdec_msg.msgcode);
queueitem.cmd = vdec_msg.msgcode;
@@ -1070,8 +1077,6 @@ static unsigned int read_frame (unsigned char *dataptr, unsigned int length,
unsigned int code = 0;
int found = 0;
- DEBUG_PRINT ("\n Inside the readframe");
-
if (dataptr == NULL || length == 0)
{
DEBUG_PRINT ("\n dataptr = %p length = %u",dataptr,length);
@@ -1093,6 +1098,7 @@ static unsigned int read_frame (unsigned char *dataptr, unsigned int length,
}
code <<= 8;
code |= (0x000000FF & dataptr[readOffset]);
+
//VOP start code comparision
if (readOffset>3)
{
@@ -1100,11 +1106,11 @@ static unsigned int read_frame (unsigned char *dataptr, unsigned int length,
{
if( VOP_START_CODE == code)
{
- DEBUG_PRINT ("\n Found VOP Code");
header_code = VOP_START_CODE;
}
else if ( (0xFFFFFC00 & code) == SHORT_HEADER_START_CODE )
{
+ DEBUG_PRINT ("\n prasanth Found SHORT_HEADER_START_CODE");
header_code = SHORT_HEADER_START_CODE;
}
}
@@ -1133,18 +1139,18 @@ static unsigned int read_frame (unsigned char *dataptr, unsigned int length,
/* End of Critical Section*/
if (found == 1)
{
- //DEBUG_PRINT ("Found a Frame");
+ DEBUG_PRINT ("\nread_frame Found a Frame adn length : %d, code : 0x%x",readOffset,code);
return (readOffset+1);
}
else
{
- //DEBUG_PRINT ("No Frames detected");
+ DEBUG_PRINT ("No Frames detected");
return 0;
}
}
else
{
-
+ DEBUG_PRINT ("\n else part of the Inside the readframe Code_type : %d",Code_type);
readOffset = Read_Buffer_From_DAT_File(dataptr,length,inputBufferFile);
if (total_frames == 0)
{
@@ -1162,7 +1168,6 @@ static int Read_Buffer_From_DAT_File(unsigned char *dataptr, unsigned int length
FILE * inputBufferFile)
{
-
long frameSize=0;
char temp_buffer[10];
char temp_byte;
diff --git a/decoder_driver_test.h b/decoder_driver_test.h
index dd95e5e..cbdddaf 100644
--- a/decoder_driver_test.h
+++ b/decoder_driver_test.h
@@ -32,11 +32,19 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <inttypes.h>
-#include <linux/msm_vidc_dec.h>
+#include "msm_vidc_dec.h"
+#include "msm_ion.h"
#include <pthread.h>
#include <semaphore.h>
#include <stdio.h>
+struct vdec_ion
+{
+ int ion_device_fd;
+ struct ion_fd_data fd_ion_data;
+ struct ion_allocation_data ion_alloc_data;
+};
+
struct video_decoder_context
{
enum vdec_codec decoder_format;
@@ -44,12 +52,15 @@ struct video_decoder_context
struct vdec_picsize video_resoultion;
struct vdec_allocatorproperty input_buffer;
struct vdec_allocatorproperty output_buffer;
- struct vdec_bufferpayload **ptr_inputbuffer;
- struct vdec_bufferpayload **ptr_outputbuffer;
- struct vdec_output_frameinfo **ptr_respbuffer;
+ struct vdec_bufferpayload *ptr_inputbuffer;
+ struct vdec_bufferpayload *ptr_outputbuffer;
+ struct vdec_output_frameinfo *ptr_respbuffer;
struct video_queue_context queue_context;
int video_driver_fd;
+ struct vdec_ion *ip_buf_ion_info;
+ struct vdec_ion *op_buf_ion_info;
+
FILE * inputBufferFile;
FILE * outputBufferFile;
diff --git a/msm_ion.h b/msm_ion.h
index 7451e89..4292fa3 100644
--- a/msm_ion.h
+++ b/msm_ion.h
@@ -18,7 +18,7 @@
****************************************************************************/
#ifndef _LINUX_MSM_ION_H
#define _LINUX_MSM_ION_H
-#include <linux/ion.h>
+#include "ion.h"
#define ION_HEAP_TYPE_MSM_START (ION_HEAP_TYPE_CUSTOM + 1)
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define ION_HEAP_TYPE_IOMMU (ION_HEAP_TYPE_MSM_START)
diff --git a/msm_vidc_dec.h b/msm_vidc_dec.h
index 66b2a30..7092ccb 100644
--- a/msm_vidc_dec.h
+++ b/msm_vidc_dec.h
@@ -89,9 +89,9 @@
#define VDEC_CMD_SET_INTF_VERSION (VDEC_CMDBASE)
#define VDEC_IOCTL_MAGIC 'v'
struct vdec_ioctl_msg {
- void __user *in;
+ void *in;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- void __user *out;
+ void *out;
};
#define VDEC_IOCTL_GET_PROFILE_LEVEL_SUPPORTED _IOWR(VDEC_IOCTL_MAGIC, 0, struct vdec_ioctl_msg)
#define VDEC_IOCTL_GET_INTERLACE_FORMAT _IOR(VDEC_IOCTL_MAGIC, 1, struct vdec_ioctl_msg)
@@ -176,7 +176,7 @@ struct vdec_allocatorproperty {
};
struct vdec_bufferpayload {
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- void __user *bufferaddr;
+ void *bufferaddr;
size_t buffer_len;
int pmem_fd;
size_t offset;
@@ -457,19 +457,19 @@ struct vdec_picsize {
};
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct vdec_seqheader {
- void __user *ptr_seqheader;
+ void *ptr_seqheader;
size_t seq_header_len;
int pmem_fd;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
size_t pmem_offset;
};
struct vdec_mberror {
- void __user *ptr_errormap;
+ void *ptr_errormap;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
size_t err_mapsize;
};
struct vdec_input_frameinfo {
- void __user *bufferaddr;
+ void *bufferaddr;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
size_t offset;
size_t datalen;
@@ -479,7 +479,7 @@ struct vdec_input_frameinfo {
void *client_data;
int pmem_fd;
size_t pmem_offset;
- void __user *desc_addr;
+ void *desc_addr;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
uint32_t desc_size;
};
@@ -498,12 +498,12 @@ struct vdec_aspectratioinfo {
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
};
struct vdec_sep_metadatainfo {
- void __user *metabufaddr;
+ void *metabufaddr;
uint32_t size;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
};
struct vdec_output_frameinfo {
- void __user *bufferaddr;
+ void *bufferaddr;
size_t offset;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
size_t len;