/****************************************************************************** * Framecopy_resizer_accel_create ******************************************************************************/ Framecopy_Handle Framecopy_resizer_accel_create(Framecopy_Attrs *attrs) { #if defined(CONFIG_VIDEO_OMAP34XX_ISP_RESIZER) Framecopy_Handle hFc; Dmai_dbg0("Creating resizer accelerated framecopy\n"); hFc = (Framecopy_Handle)calloc(1, sizeof(Framecopy_Object)); if (hFc == NULL) { Dmai_err0("Failed to allocate space for Framecopy Object\n"); return NULL; } /* Open resizer device */ hFc->fd = open(RESIZER_DEVICE, O_RDWR); if (hFc->fd == -1) { Dmai_err1("Failed to open %s\n", RESIZER_DEVICE); return NULL; } return hFc; #else Dmai_err0("not implemented\n"); return NULL; #endif /* end CONFIG_VIDEO_OMAP34XX_ISP_RESIZER */ }
/****************************************************************************** * Dmai_setLogLevel ******************************************************************************/ Int Dmai_setLogLevel(Dmai_LogLevel logLevel) { /* Set the log level if global variable is not set */ if (Dmai_debugLogLevel == Dmai_LogLevel_Notset) { switch (logLevel) { case 0: GT_set("ti.sdo.dmai="); break; case 1: GT_set("ti.sdo.dmai=67"); break; case 2: GT_set("ti.sdo.dmai=01234567"); break; default: /* Invalid level. */ return Dmai_EINVAL; } Dmai_dbg1("Log level set to %d.\n", logLevel); } else { Dmai_dbg0("Using log level set by DMAI_DEBUG.\n"); } return Dmai_EOK; }
/****************************************************************************** * Initialize & configure resizer B in on-the-fly (continous) mode ******************************************************************************/ int Resizer_B_config(int rsz_fd, unsigned int width, unsigned int height) { unsigned int user_mode; struct rsz_channel_config rsz_chan_config; struct rsz_continuous_config rsz_cont_config; user_mode = IMP_MODE_CONTINUOUS; if(rsz_fd <= 0) { Dmai_err0("Cannot use resize device \n"); return NULL; } bzero(&rsz_cont_config, sizeof(struct rsz_continuous_config)); rsz_chan_config.oper_mode = user_mode; rsz_chan_config.chain = 1; rsz_chan_config.len = sizeof(struct rsz_continuous_config); rsz_chan_config.config = &rsz_cont_config; if (ioctl(rsz_fd, RSZ_G_CONFIG, &rsz_chan_config) < 0) { Dmai_err1("Error in getting channel configuration from resizer (%s)\n", strerror(errno)); return Dmai_EFAIL; } /* we can ignore the input spec since we are chaining. So only set output specs */ rsz_cont_config.output2.width = width; rsz_cont_config.output2.height= height; rsz_cont_config.output2.pix_fmt = IPIPE_YUV420SP; rsz_cont_config.output2.enable = 1; rsz_chan_config.len = sizeof(struct rsz_continuous_config); rsz_chan_config.config = &rsz_cont_config; if (ioctl(rsz_fd, RSZ_S_CONFIG, &rsz_chan_config) < 0) { Dmai_err1("Error in setting resizer configuration (%s)\n", strerror(errno)); return Dmai_EFAIL; } Dmai_dbg0("Resizer B initialized\n"); return Dmai_EOK; }
/****************************************************************************** * Idec1_create ******************************************************************************/ Idec1_Handle Idec1_create(Engine_Handle hEngine, Char *codecName, IMGDEC1_Params *params, IMGDEC1_DynamicParams *dynParams) { Idec1_Handle hId; IMGDEC1_Handle hDecode; IMGDEC1_Status decStatus; XDAS_Int32 status; if (hEngine == NULL || codecName == NULL || params == NULL || dynParams == NULL) { Dmai_err0("Cannot pass null for engine, codec name, params or " "dynamic params\n"); return NULL; } /* Allocate space for the object */ hId = (Idec1_Handle)calloc(1, sizeof(Idec1_Object)); if (hId == NULL) { Dmai_err0("Failed to allocate space for Idec1 Object\n"); return NULL; } /* Create image decoder instance */ hDecode = IMGDEC1_create(hEngine, codecName, params); if (hDecode == NULL) { Dmai_err0("Failed to open image decode algorithm\n"); free(hId); return NULL; } Dmai_dbg0("Image decoder instance created\n"); /* Set image decoder dynamic params */ decStatus.data.buf = NULL; decStatus.size = sizeof(IMGDEC1_Status); status = IMGDEC1_control(hDecode, XDM_SETPARAMS, dynParams, &decStatus); if (status != IMGDEC1_EOK) { Dmai_err0("XDM_SETPARAMS control failed\n"); IMGDEC1_delete(hDecode); free(hId); return NULL; } /* Get buffer information from image decoder */ status = IMGDEC1_control(hDecode, XDM_GETBUFINFO, dynParams, &decStatus); if (status != IMGDEC1_EOK) { Dmai_err0("XDM_GETBUFINFO control failed\n"); IMGDEC1_delete(hDecode); free(hId); return NULL; } Dmai_dbg1("Buffer size %u obtained from XDM_GETBUFINFO control call\n", (UInt) decStatus.bufInfo.minInBufSize[0]); hId->hDecode = hDecode; memcpy(hId->minInBufSize, decStatus.bufInfo.minInBufSize, sizeof(hId->minInBufSize)); hId->minNumInBufs = decStatus.bufInfo.minNumInBufs; memcpy(hId->minOutBufSize, decStatus.bufInfo.minOutBufSize, sizeof(hId->minOutBufSize)); hId->minNumOutBufs = decStatus.bufInfo.minNumOutBufs; return hId; }
/****************************************************************************** * Initialize & configure previewer in on-the-fly (continous) mode ******************************************************************************/ Int Previewer_continous_config(void) { Int preview_fd; unsigned int oper_mode, user_mode; struct prev_channel_config prev_chan_config; struct prev_continuous_config prev_cont_config; user_mode = IMP_MODE_CONTINUOUS; preview_fd = open((const char *)PREVIEWER_DEVICE, O_RDWR); if(preview_fd <= 0) { Dmai_err0("Cannot open previewer device \n"); return NULL; } if (ioctl(preview_fd,PREV_S_OPER_MODE, &user_mode) < 0) { Dmai_err1("Can't set operation mode in previewer (%s)\n", strerror(errno)); close(preview_fd); return Dmai_EFAIL; } if (ioctl(preview_fd,PREV_G_OPER_MODE, &oper_mode) < 0) { Dmai_err1("Can't get operation mode from previewer (%s)\n", strerror(errno)); close(preview_fd); return Dmai_EFAIL; } if (oper_mode == user_mode) { Dmai_dbg0("Operating mode changed successfully to continuous in previewer\n"); } else { Dmai_err0("failed to set mode to continuous in previewer\n"); close(preview_fd); return Dmai_EFAIL; } prev_chan_config.oper_mode = oper_mode; prev_chan_config.len = 0; prev_chan_config.config = NULL; /* to set defaults in driver */ if (ioctl(preview_fd, PREV_S_CONFIG, &prev_chan_config) < 0) { Dmai_err1("Error in setting default previewer configuration (%s)\n", strerror(errno)); close(preview_fd); return Dmai_EFAIL; } prev_chan_config.oper_mode = oper_mode; prev_chan_config.len = sizeof(struct prev_continuous_config); prev_chan_config.config = &prev_cont_config; if (ioctl(preview_fd, PREV_G_CONFIG, &prev_chan_config) < 0) { Dmai_err1("Error in getting configuration from previewer (%s)\n", strerror(errno)); close(preview_fd); return Dmai_EFAIL; } prev_chan_config.oper_mode = oper_mode; prev_chan_config.len = sizeof(struct prev_continuous_config); prev_chan_config.config = &prev_cont_config; if (ioctl(preview_fd, PREV_S_CONFIG, &prev_chan_config) < 0) { Dmai_err1("Error in setting previewer configuration (%s)\n", strerror(errno)); close(preview_fd); return Dmai_EFAIL; } Dmai_dbg0("Previewer initialized\n"); return preview_fd; }
/****************************************************************************** * Initialize & configure resizer in on-the-fly (continous) mode ******************************************************************************/ Int Resizer_continous_config(void) { Int rsz_fd; unsigned int oper_mode, user_mode; struct rsz_channel_config rsz_chan_config; struct rsz_continuous_config rsz_cont_config; user_mode = IMP_MODE_CONTINUOUS; rsz_fd = open((const char *)RESIZER_DEVICE, O_RDWR); if(rsz_fd <= 0) { Dmai_err0("Cannot open resize device \n"); return NULL; } if (ioctl(rsz_fd, RSZ_S_OPER_MODE, &user_mode) < 0) { Dmai_err1("Can't set operation mode (%s)\n", strerror(errno)); close(rsz_fd); return Dmai_EFAIL; } if (ioctl(rsz_fd, RSZ_G_OPER_MODE, &oper_mode) < 0) { Dmai_err1("Can't get operation mode (%s)\n", strerror(errno)); close(rsz_fd); return Dmai_EFAIL; } if (oper_mode == user_mode) { Dmai_dbg0("Successfully set mode to continuous in resizer\n"); } else { Dmai_err0("Failed to set mode to continuous in resizer\n"); close(rsz_fd); return Dmai_EFAIL; } /* set configuration to chain resizer with preview */ rsz_chan_config.oper_mode = user_mode; rsz_chan_config.chain = 1; rsz_chan_config.len = 0; rsz_chan_config.config = NULL; /* to set defaults in driver */ if (ioctl(rsz_fd, RSZ_S_CONFIG, &rsz_chan_config) < 0) { Dmai_err1("Error in setting default configuration in resizer (%s)\n", strerror(errno)); close(rsz_fd); return Dmai_EFAIL; } bzero(&rsz_cont_config, sizeof(struct rsz_continuous_config)); rsz_chan_config.oper_mode = user_mode; rsz_chan_config.chain = 1; rsz_chan_config.len = sizeof(struct rsz_continuous_config); rsz_chan_config.config = &rsz_cont_config; if (ioctl(rsz_fd, RSZ_G_CONFIG, &rsz_chan_config) < 0) { Dmai_err1("Error in getting channel configuration from resizer (%s)\n", strerror(errno)); close(rsz_fd); return Dmai_EFAIL; } /* we can ignore the input spec since we are chaining. So only set output specs */ rsz_cont_config.output1.enable = 1; rsz_cont_config.output2.enable = 0; rsz_chan_config.len = sizeof(struct rsz_continuous_config); rsz_chan_config.config = &rsz_cont_config; if (ioctl(rsz_fd, RSZ_S_CONFIG, &rsz_chan_config) < 0) { Dmai_err1("Error in setting resizer configuration (%s)\n", strerror(errno)); close(rsz_fd); return Dmai_EFAIL; } Dmai_dbg0("Resizer A initialized\n"); return rsz_fd; }
/****************************************************************************** * Capture_detectVideoStd ******************************************************************************/ Int Capture_detectVideoStd(Capture_Handle hCapture, VideoStd_Type *videoStdPtr, Capture_Attrs *attrs) { v4l2_std_id id; struct v4l2_input input; Int index; Int fd; struct v4l2_standard std; assert(videoStdPtr); assert(attrs); if (attrs->videoStd < 0 || attrs->videoStd > VideoStd_COUNT) { Dmai_err1("Invalid capture standard given (%d)\n", attrs->videoStd); return Dmai_EINVAL; } if (hCapture) { fd = hCapture->fd; } else { fd = open(attrs->captureDevice, O_RDWR, 0); if (fd == -1) { Dmai_err2("Cannot open %s (%s)\n", attrs->captureDevice, strerror(errno)); return Dmai_EFAIL; } } /* Get any active input */ if (ioctl(fd, VIDIOC_G_INPUT, &index) < 0) { Dmai_err0("VIDIOC_G_INPUT"); return Dmai_EFAIL; } /* Display available video input */ Dmai_dbg0("Available video input:\n"); for (index=0;; index++) { input.index = index; if (ioctl(fd, VIDIOC_ENUMINPUT, &input) < 0) { if (errno == EINVAL || errno == ENOTTY) break; } Dmai_dbg1(" name=%s\n", input.name); } /* Set video input */ switch (attrs->videoInput) { case Capture_Input_SVIDEO: Dmai_dbg0("Setting video input to SVIDEO\n"); index = 1; break; case Capture_Input_COMPOSITE: Dmai_dbg0("Setting video input to COMPOSITE\n"); index = 0; break; default: Dmai_err0("Unknown video input\n"); return Dmai_EFAIL; break; } if (ioctl(fd, VIDIOC_S_INPUT, &index) < 0) { Dmai_err2("Failed VIDIOC_S_INPUT to index %d (%s)\n", index, strerror(errno)); return Dmai_EFAIL; } /* Display available video standards */ Dmai_dbg0("Available video standard:\n"); for (index=0;; index++) { std.frameperiod.numerator = 1; std.frameperiod.denominator = 0; std.index = index; if (ioctl(fd, VIDIOC_ENUMSTD, &std) < 0) { if (errno == EINVAL || errno == ENOTTY) break; } Dmai_dbg3(" name=%s, fps=%d/%d\n", std.name, std.frameperiod.denominator, std.frameperiod.numerator); } /* Detect the standard in the input detected */ if (ioctl(fd, VIDIOC_QUERYSTD, &id) < 0) { Dmai_err0("VIDIOC_QUERYSTD"); return Dmai_EFAIL; } /* Get current video standard */ if (ioctl(fd, VIDIOC_G_STD, &id) < 0) { Dmai_err0("Failed VIDIOC_G_STD\n"); return Dmai_EFAIL; } if (!hCapture) { close(fd); } if (id & V4L2_STD_NTSC) { *videoStdPtr = VideoStd_D1_NTSC; Dmai_dbg0("Found NTSC std input\n"); } else if (id & V4L2_STD_PAL) { *videoStdPtr = VideoStd_D1_PAL; Dmai_dbg0("Found PAL std input\n"); } else if (id & V4L2_STD_525_60) { *videoStdPtr = VideoStd_480P; Dmai_dbg0("Found 525_60 std input\n"); } else if (id & V4L2_STD_625_50) { *videoStdPtr = VideoStd_576P; Dmai_dbg0("Found 625_50 std input\n"); } else { Dmai_err1("Unknown video standard on capture device %s\n", attrs->captureDevice); return Dmai_EFAIL; } attrs->videoStd = *videoStdPtr; Dmai_dbg2("Capture input set to %s. Standard: %d\n", captureInputString[attrs->videoInput], *videoStdPtr); return Dmai_EOK; }
/****************************************************************************** * Initialize & configure previewer in on-the-fly (continous) mode ******************************************************************************/ Int Previewer_continuous_config(Bool setRgbColorPallet) { #ifdef CONFIG_DM365_IPIPE Int preview_fd; unsigned int oper_mode, user_mode; struct prev_channel_config prev_chan_config; struct prev_continuous_config prev_cont_config; struct prev_cap cap; struct prev_module_param mod_param; user_mode = IMP_MODE_CONTINUOUS; preview_fd = open((const char *)PREVIEWER_DEVICE, O_RDWR); if(preview_fd <= 0) { Dmai_err0("Cannot open previewer device \n"); return NULL; } if (ioctl(preview_fd,PREV_S_OPER_MODE, &user_mode) < 0) { Dmai_err1("Can't set operation mode in previewer (%s)\n", strerror(errno)); close(preview_fd); return Dmai_EFAIL; } if (ioctl(preview_fd,PREV_G_OPER_MODE, &oper_mode) < 0) { Dmai_err1("Can't get operation mode from previewer (%s)\n", strerror(errno)); close(preview_fd); return Dmai_EFAIL; } if (oper_mode == user_mode) { Dmai_dbg0("Operating mode changed successfully to continuous in previewer\n"); } else { Dmai_err0("failed to set mode to continuous in previewer\n"); close(preview_fd); return Dmai_EFAIL; } prev_chan_config.oper_mode = oper_mode; prev_chan_config.len = 0; prev_chan_config.config = NULL; /* to set defaults in driver */ if (ioctl(preview_fd, PREV_S_CONFIG, &prev_chan_config) < 0) { Dmai_err1("Error in setting default previewer configuration (%s)\n", strerror(errno)); close(preview_fd); return Dmai_EFAIL; } if (setRgbColorPallet) { Dmai_dbg0("Setting RGB color pallet\n"); prev_chan_config.oper_mode = oper_mode; prev_chan_config.len = sizeof(struct prev_continuous_config); prev_chan_config.config = &prev_cont_config; /* to set defaults in driver */ if (ioctl(preview_fd, PREV_G_CONFIG, &prev_chan_config) < 0) { Dmai_err1("Error in setting default previewer configuration (%s)\n", strerror(errno)); close(preview_fd); return Dmai_EFAIL; } prev_chan_config.oper_mode = oper_mode; prev_chan_config.len = sizeof(struct prev_continuous_config); prev_chan_config.config = &prev_cont_config; /* to set defaults in driver */ prev_cont_config.input.colp_elep= IPIPE_BLUE; prev_cont_config.input.colp_elop= IPIPE_GREEN_BLUE; prev_cont_config.input.colp_olep= IPIPE_GREEN_RED; prev_cont_config.input.colp_olop= IPIPE_RED; if (ioctl(preview_fd, PREV_S_CONFIG, &prev_chan_config) < 0) { Dmai_err1("Error in setting default previewer configuration (%s)\n", strerror(errno)); close(preview_fd); return Dmai_EFAIL; } cap.index=0; while (1) { if (ioctl(preview_fd , PREV_ENUM_CAP, &cap) < 0) { break; } strcpy(mod_param.version,cap.version); mod_param.module_id = cap.module_id; // using defaults Dmai_dbg1("Setting default for %s\n", cap.module_name); mod_param.param = NULL; if (ioctl(preview_fd, PREV_S_PARAM, &mod_param) < 0) { Dmai_err1("Error in Setting %s params from driver\n", cap.module_name); close(preview_fd); return Dmai_EFAIL; } cap.index++; } } Dmai_dbg0("Previewer initialized\n"); return preview_fd; #else Dmai_err0("not implemented\n"); return Dmai_ENOTIMPL; #endif }