• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Digital Signal Processors (DSP) » DaVinci™ Video Processors » DM3x DaVinci Video Processor Forum » DM355 previewer programming
Share
DaVinci™ Video Processors
  • Forums
  • Announcements
Options
  • Subscribe via RSS

DM355 previewer programming

DM355 previewer programming

This question is not answered
Mikhail Smagin
Posted by Mikhail Smagin
on Apr 02 2012 06:02 AM
Intellectual320 points

                                Dear All!

I am trying to sort out with DM355 previer. I've wrote a simple program - actually it is mostly the copy of example. I try to make it work on DM355 DVEVM.  It compiles successfully and works properly till the PREV_PREVIEW ioctl, where it hangs permanently. I've lost about a week trying to make it working, but had no success. Could you please tell me, what am I doing wrong. Here is the listing:

#include <stdio.h>
#include <media/davinci/dm355_ipipe.h>
#include <media/davinci/imp_previewer.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <media/davinci/imp_common.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "try_ipipe.h"
#include <string.h>
#include <sys/mman.h>

#define WIDTH 1296
#define HEIGHT 972
#define INBUFSNUM 1
#define OUTBUFSNUM 1
#define BYTESPERLINE 2

unsigned int preview_fd, oper_mode, user_mode;
int ret, expected_size, size, i, outwidth, outheight, outsize;

char inbuf[WIDTH*HEIGHT];
char *input_buffer, *output_buffer;

struct prev_channel_config prev_chan_par;
struct prev_single_shot_config prev_ss_config;
struct prev_cap cap;
struct prev_module_param mod_param;
struct imp_reqbufs reqbuf_params;
struct imp_buffer inbuf_params[INBUFSNUM], outbuf_params[OUTBUFSNUM];
struct imp_convert conv_params;

FILE *infile, *outfile;

int main(void)
{   
//Opening the Previewer
    preview_fd=open("/dev/davinci_previewer", O_RDWR);
 
//Setting Previewer mode
    oper_mode=IMP_MODE_SINGLE_SHOT;
    printf("Setting previewer operation mode\n");

    ioctl(preview_fd,PREV_S_OPER_MODE,&oper_mode);
    
// Setting previewer configuration
    prev_chan_par.oper_mode=oper_mode;
    prev_chan_par.len=0;
    prev_chan_par.config=NULL;
    ioctl(preview_fd,PREV_S_CONFIG,&prev_chan_par);

    prev_chan_par.oper_mode=oper_mode;
    prev_chan_par.len=sizeof(struct prev_single_shot_config);
    prev_chan_par.config=&prev_ss_config;    

    ioctl(preview_fd,PREV_G_CONFIG,&prev_chan_par)
   
    prev_ss_config.input.image_width=WIDTH;
    prev_ss_config.input.image_height=HEIGHT;
    ioctl(preview_fd,PREV_S_CONFIG,&prev_chan_par);
 

// IPIPE modules cycle initialisation

    cap.index=0;
    while (1)
    {
        ret=ioctl(preview_fd, PREV_ENUM_CAP, &cap);
        if (ret<0)
        {
            break;
        }
        strcpy(mod_param.version,cap.version);
        mod_param.module_id=cap.module_id;
        mod_param.param = NULL;
        ioctl(preview_fd, PREV_S_PARAM, &mod_param)
        cap.index++;
    }    
  
//Buffers initialisation
    
    expected_size=WIDTH*HEIGHT;   
    outwidth=WIDTH;
    outheight=HEIGHT;
    
    outwidth += 15;
    outwidth &= (~15);
    outsize = outwidth * outheight * BYTESPERLINE;
   
    infile=fopen("capture_8.raw", "rb");
    size=fread(inbuf,1,expected_size,infile);
   
    reqbuf_params.buf_type=IMP_BUF_IN;
    reqbuf_params.size=size;
    reqbuf_params.count=INBUFSNUM;    

    ioctl(preview_fd,PREV_REQBUF,&reqbuf_params)
   
    for (i=0;i<INBUFSNUM;i++)
    {
        inbuf_params[i].index=i;
        inbuf_params[i].buf_type=IMP_BUF_IN;
        ioctl(preview_fd, PREV_QUERYBUF, &inbuf_params[i])
    }
    
    reqbuf_params.buf_type=IMP_BUF_OUT1;
    reqbuf_params.size=outsize;
    reqbuf_params.count=OUTBUFSNUM;
    ioctl(preview_fd,PREV_REQBUF,&reqbuf_params)
    
    for (i=0;i<OUTBUFSNUM;i++)
    {
        outbuf_params[i].index=i;
        outbuf_params[i].buf_type=IMP_BUF_OUT1;
        ioctl(preview_fd, PREV_QUERYBUF, &outbuf_params[i]);
    }
    
    input_buffer=mmap(NULL,inbuf_params[0].size, PROT_READ|PROT_WRITE,
            MAP_SHARED, preview_fd, inbuf_params[0].offset);
    
    output_buffer=mmap(NULL,outbuf_params[0].size,PROT_READ|PROT_WRITE,
            MAP_SHARED, preview_fd, inbuf_params[0].offset);
            
//Begin the operations
    
    memcpy(input_buffer,inbuf,(WIDTH*HEIGHT));

    memset(&conv_params,'\0',sizeof(conv_params));
    
    conv_params.in_buff.index=0;
    conv_params.in_buff.buf_type=IMP_BUF_IN;
    conv_params.in_buff.offset=inbuf_params[0].offset;
    conv_params.in_buff.size=inbuf_params[0].size;
    
    conv_params.out_buff1.index=0;
    conv_params.out_buff1.buf_type=IMP_BUF_OUT1;
    conv_params.out_buff1.offset=outbuf_params[0].offset;
    conv_params.out_buff1.size=outbuf_params[0].size;

    
    ioctl(preview_fd, PREV_PREVIEW, &conv_params)
    
//Finishing preview. Output creation.
        
    outfile=fopen("720p_converted","wb");
    
   
    fwrite(output_buffer,1,size,outfile)

    printf("Output saved.Cleaning memory");

    munmap(input_buffer,inbuf_params[0].size);
    munmap(output_buffer,outbuf_params[0].size);

    fclose(infile);
    fclose(outfile);

    close(preview_fd);
    
    return 0;
    
}  

What am I doing wrong? Which of the obligatory parameters I have missed?

Thank you in advance.

 MS  

    




DM355 daVinci dm355 DVSDK 3.10
Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Prabhakar Lad
    Posted by Prabhakar Lad
    on Apr 02 2012 06:59 AM
    Genius4675 points

    Hi,

    There is already a app here Link just try it out.

    Regards,

    --Prabhakar Lad

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use