When you utilize "Memory_contigAlloc()", you're building in a dependency
on a Codec Engine API.  This API, when on Linux, simply wraps the CMEM
APIs.
 
Because 1) this app may not care about cross-OS compatibility, and 2)
you want to minimize dependencies - always a good goal, you may want to
just use the CMEM API (rather than the CE APIs).  There are Codec Engine
independent CMEM example apps in the DVEVM's
cmem_1_??/packages/ti/sdo/linuxutils/cmem/apps/* directory.
 
[ However, if this app _will_ become Codec Engine dependent, you may
want to continue using Memory_* APIs, and set up the build environment,
configuration, etc.  You can see the examples in
codec_engine_1_??/examples/* to see how to do that. ]
 
Also, don't forget to Memory_contigFree().  ;)
 
Chris


________________________________

        From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of Harrison
        Sent: Monday, February 05, 2007 1:19 AM
        To: davinci-linux-open-source
        Subject: how to compile a user space code below ?
Memory_contigAlloc() usedin it >.
        
        
        anyone can provide a makefile or the approach for compiling it ?
         
         
        it seems that XDC tools should been considered .... any help
will be appreciated ! thanks 
         
         
         
         
        #include <stdio.h>
        #include <stdlib.h>
        #include <string.h>

        #include <fcntl.h>
        #include <unistd.h>
        #include <errno.h>
        #include <sys/stat.h>
        #include <sys/types.h>
        #include <sys/time.h>
        #include <sys/mman.h>
        #include <sys/ioctl.h> 
        #include <sched.h>
        #include <pthread.h>

        #include <asm/types.h>
        #include <linux/fb.h>

        #include <xdc/std.h>
        #include <ti/sdo/ce/Engine.h>
        #include <ti/sdo/ce/osal/Memory.h>
        #include <ti/sdo/ce/CERuntime.h>

         

        
        #define D1_WIDTH 360
        #define D1_HEIGHT 240
        #define SCREEN_BPP 16
        #define D1_FRAME_SIZE D1_WIDTH*SCREEN_BPP/8
        #define READBUFSIZE D1_FRAME_SIZE*D1_HEIGHT

        #define FAILURE -1
        #define SUCCESS 0

        #define UYVY_BLACK 0x10801080
        struct Zoom_Params
        {
         unsigned int WindowID;
         unsigned int Zoom_H;
         unsigned int Zoom_V;
        };
        #define RESIZER_MAGIC 'N'
        #define SET_INPUT_ADDR _IOW(RESIZER_MAGIC,1,int) 
        #define SET_OUTPUT_ADDR _IOW(RESIZER_MAGIC,2,int)
        #define PROCESS_ONE_FRAME _IOW(RESIZER_MAGIC,3,int)

        #define FBIO_SETZOOM        _IOW('F', 0x24, struct Zoom_Params)
        #define FBIO_WAITFORVSYNC   _IOW('F', 0x20, unsigned int)
        #define FBIO_GETSTD         _IOR('F', 0x25, unsigned int)

        #define DEBUG(fmt,args...) printf(fmt,##args)

        static int initDisplayDevice(char *display[])
        {
         struct fb_var_screeninfo varInfo;
         struct Zoom_Params zoom;
         unsigned int *buf;
         int fb;
         int i;
         int std;

         fb = open("/dev/fb/3",O_RDWR);
         if (fb == -1) {
          DEBUG("open file error \n");
          return FAILURE;
         }

         if (ioctl(fb, FBIO_GETSTD, &std) == -1) {
                DEBUG("Failed to get video standard from display device
driver\n");
                return FAILURE;
                 }
         if ((std >> 16) == 0x1) {
                DEBUG("NTSC selected\n"); 
           }else {
                DEBUG("PAL selected\n");  
                 }

         if (ioctl(fb, FBIOGET_VSCREENINFO, &varInfo) == -1) {
                DEBUG("Failed FBIOGET_VSCREENINFO \n");
                return FAILURE;
             }

            varInfo.xres = D1_WIDTH;
            varInfo.yres = D1_HEIGHT;
            varInfo.bits_per_pixel = SCREEN_BPP;
         
          if (ioctl(fb, FBIOPUT_VSCREENINFO, &varInfo) == -1) {
                DEBUG("Failed FBIOPUT_VSCREENINFO \n"); 
                return FAILURE;
                   }

            if (varInfo.xres != D1_WIDTH ||
                varInfo.yres != D1_HEIGHT ||
                varInfo.bits_per_pixel != SCREEN_BPP) {
                DEBUG("Failed to get the requested screen size: %dx%d at
%d bpp\n",D1_WIDTH,D1_HEIGHT, SCREEN_BPP); 
                return FAILURE;
             }

          display[0] = (char *) mmap (NULL,D1_FRAME_SIZE,PROT_READ |
PROT_WRITE,MAP_SHARED,fb,0);
          buf = (unsigned int *) display[0];

         for (i=0; i<D1_FRAME_SIZE / sizeof(unsigned int); i++) {
                buf[i] = UYVY_BLACK;
                }

          zoom.WindowID = 1; //VID1_INDEX
            zoom.Zoom_H = 0;  //ZOOM_1X
            zoom.Zoom_V = 0;  //ZOOM_1X

         if (ioctl(fb, FBIO_SETZOOM, &zoom)) {
                DEBUG("Failed setting zoom parameters\n");
                return FAILURE;
             }
         
         return fb;

        }

        
        int main(){

         int  resizer,fb,pic,numBytes;
         char * readBuf;
         char *display[1];

         resizer = open("/dev/resizer", O_RDWR);
         if (resizer == -1) {
          DEBUG("open file error \n");
          return FAILURE;
         }
         
         fb = initDisplayDevice(display);
         DEBUG("init display device is ok! \n"); 
         if(fb==FAILURE){
          close(resizer);
          return FAILURE;
         }
         pic = open("/pic", O_RDWR);
         if (pic == -1) {
          DEBUG("open file error \n");
          return FAILURE;
         }
         DEBUG("open picture ok! \n"); 
         readBuf=(char
*)Memory_contigAlloc(READBUFSIZE,Memory_DEFAULTALIGNMENT);
         if(readBuf == NULL){
          DEBUG("fail to allocate contilsguous memory block.\n");
          goto fail;
         }
         DEBUG("READ PIC\n"); 
         numBytes = read(pic,readBuf,READBUFSIZE);
         if(numBytes != READBUFSIZE){
          DEBUG("fail to read the whole pic.\n");
          return FAILURE;
         }
         DEBUG("SET_INPUT_ADDR\n");
        
if(ioctl(resizer,SET_INPUT_ADDR,(Memory_getPhysicalAddress(readBuf))) ==
-1){ 
          DEBUG("set input addr error.\n");
          return FAILURE;
         }
         DEBUG("SET_OUTPUT_ADDR\n");
        
if(ioctl(resizer,SET_OUTPUT_ADDR,(Memory_getPhysicalAddress(display[0]))
) == -1){
          DEBUG("set input addr error.\n"); 
          return FAILURE;
         }
         DEBUG("PROCESS_ONE_FRAME\n");
         if(ioctl(resizer,PROCESS_ONE_FRAME,0x00000001) == -1){
          DEBUG("set input addr error.\n");
          return FAILURE;
         }

          fail:
         close(resizer);
         close(fb);
         close(pic);

         return 0;

        }

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to