⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 play_capture.c

📁 Sample code for use on smp 863x processor.
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * * Copyright (c) 2001-2007 Sigma Designs, Inc.  * All Rights Reserved. Proprietary and Confidential. * *//**	@file play_capture.c	@brief sample application to access the 86xx chip family		@author Christian Wolff*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#define ALLOW_OS_CODE 1//#include "../dcc/include/dcc.h"#include "../rua/include/rua.h"#include "../rua/include/rua_property.h"#include "../rmcore/include/rmstatustostring.h"#include "../emhwlib_hal/pll/include/pll_hal.h"#include "command_ids.h"#include "get_key.h"#include "common.h"// to enable or disable the debug messages of this source file, put 1 or 0 below#if 0#define LOCALDBG ENABLE#else#define LOCALDBG DISABLE#endif// define here, and in ucode_lib/ucode/audio/common_new/audio.feedback.asm// to check captured PCM audio for triangle waveform:// odd on L, |Ln - Ln-1| = 2, |Rn - Rn-1| = 2, |Ln - Rn| = 1//#define CHECK_TRIANGLE 1// zoom helper defines and functions#undef ZOOM_0#undef ZOOM_1#define ZOOM_0 4096  // 0% zoom position#define ZOOM_1 8192  // 100% zoom position#define AUDIO_GUARD_TIME 2  // wait 2 seconds after audio has been set up until audio passtrough can be restarted#define AUDIO_FIFO_SIZE (2048*1024)#define XFER_FIFO_COUNT (32)RMuint32 I2C_ModuleID = I2C;static RMuint8 cc_buf[256], dtv_buf[128];static RMuint32 cc_size = 0, dtv_size = 0;RMuint32 TimerNumber = 1;#define SCANPARAM(x, msg, skip)\do {\	argi++;\	if (argi < argc) {\		param = strtoul(argv[argi], &endptr, 0);\		if (endptr[0] == '\0') x = param;\		else {\			fprintf(stderr, msg " after %s\n", argv[argi - skip]);\			err = RM_ERROR;\		}\	} else {\		fprintf(stderr, "Please specify %d number%s after %s\n", skip, (skip == 1) ? "" : "s", argv[argi - skip]);\		err = RM_ERROR;\	}\} while(0)#define RUASetPendingProperty(inst, mod, prop, paramptr, paramsize, text) do { \	do { \		err = RUASetProperty(inst, mod, prop, paramptr, paramsize, 0); \	} while (err == RM_PENDING); \	if (RMFAILED(err)) { \		RMDBGLOG((ENABLE, text ": %s\n", RMstatusToString(err))); \		return err; \	} \} while (0)struct display_cmdline disp_opt;struct capture_cmdline capture_opt[2];struct audio_cmdline audio_opt;enum capture_chip {	cap_NoChip, 	cap_ADV7402, 	cap_SAA7119,	cap_WM8775, 	cap_MSP34x5};enum capture_port {	cap_Direct, 	cap_CVBS1, 	cap_CVBS2, 	cap_SVideo1, 	cap_SVideo2, 	cap_ScartCVBS1, 	cap_ScartCVBS2, 	cap_ScartRGB1, 	cap_ScartRGB2, 	cap_Tuner1, 	cap_Tuner2, 	cap_Component1, 	cap_Component2, 	cap_VGA, 	cap_HDMI0, 	cap_HDMI1, };enum capture_board {	cap_kissjamoplasma, 	cap_sigma775avinput, 	cap_sigma760e1hdref, 	cap_sigma760e2hdlcd, 	cap_sigma844e1dtv, 	cap_pioneer809e1video, };RMuint32 chip_num;RMuint32 input_num;struct avi_info {	RMbool valid;	RMuint32 scan_info;     // S	RMbool v_bar;           // B0	RMbool h_bar;           // B1	RMuint32 active_format; // A, R	RMuint32 color_format;  // Y	RMuint32 aspect_ratio;  // M	RMuint32 color_space;   // C	RMuint32 scaling;       // SC	RMuint32 quantisation;  // Q	RMuint32 ext_col;       // EC	RMbool it_content;      // ITC	RMuint32 vic;           // VIC	RMuint32 pixel_rep;     // PR	RMuint32 in_pixel_rep;  // PR on the output of the HDMI chip, after reduction	RMuint32 top;	RMuint32 bottom;	RMuint32 left;	RMuint32 right;};enum hdmi_mode {	mode_unknown, 	mode_HDMI, 	mode_DVI};enum audio_state {	audio_state_off,     // no audio present	audio_state_request, // request audio, wait 200 mSec for stable clock	audio_state_on       // audio is running};struct local_cmdline {	RMbool zoom_force;	RMuint32 zoom_x;	RMuint32 zoom_y;	RMuint32 zoom_w;	RMuint32 zoom_h;	RMbool force_overscan_crop;	RMuint32 overscan_crop_amount;	RMuint32 overscan_crop;  // percentage of frame size to crop around edge for overscanned pictures	struct EMhwlibDisplayWindow *output_window;	RMuint32 arg_vbi;	RMbool parse_anc;	RMbool print_anc;	RMbool dump_vbi;	RMbool i2c_init;	RMuint32 i2c_module;	enum capture_board i2c_board;	enum capture_port i2c_port;	enum capture_chip i2c_video_chip;	RMuint8 i2c_video_dev;	RMuint32 i2c_video_delay;	enum capture_chip i2c_audio1_chip;	RMuint8 i2c_audio1_dev;	RMuint32 i2c_audio1_delay;	enum capture_chip i2c_audio2_chip;	RMuint8 i2c_audio2_dev;	RMuint32 i2c_audio2_delay;	RMbool enable_i2c_cc;	RMbool enable_i2c_wss;	struct EMhwlibInputReadbackI2CCC i2c_cc;	RMbool ccfifo_print;	RMuint32 use_soft_cc_decoder;	RMuint32 ccfifo_id_in;	RMuint32 ccfifo_id_send;	RMuint32 ccfifo_id_out;	RMuint32 ccfifo_addr_in;	RMuint32 ccfifo_addr_out;	RMuint32 VBIFlags;	RMuint32 VBIPTS;	RMuint32 VBISequence;	RMuint32 VBISize;	RMuint32 VBIOffs;	RMuint16 *pVBIChunk;	RMuint16 *pVBIData;	FILE *vbidump;	RMbool update;	RMbool use_gpio_fid;	RMbool invert_fid;	RMbool last_hotplug;	struct ReceiveObject_type *pR;	struct RUABufferPool *pDmaReceive;	RMbool force_active_format;	enum EMhwlibActiveFormat active_format;	RMbool force_wide_screen;	RMbool wide_screen;	RMuint32 wss_odd;	RMuint32 wss_even;	RMbool last_hdcp_ok;	RMbool last_power;	RMbool last_sync;	RMbool last_clock;	RMbool last_auth;	RMbool last_crypt;	RMbool break_hdcp;	RMuint32 cable_eq;	struct avi_info last_avi;	RMbool new_avi;	enum EMhwlibScanInfo last_scan;	RMbool update_videomode;	RMbool follow_vfreq;	RMbool verbouse;	RMbool intr_debug;	RMbool green_bg;	enum hdmi_mode hdmi_mode;  // TRUE: HDMI with info frames, audio etc. FALSE: DVI mode	RMbool upsample_from_422;	RMuint32 CurrChStat;	RMuint16 CurrPc;	RMuint8 last_isrc[32];	RMuint8 last_isrc_header;	RMbool last_isrc2;	RMuint8 intr_mask[6];	enum audio_state audio_state;	RMuint64 audio_guard_time;	RMbool restart_audio;  // have to restart audio passthrough due to errors or changes	RMbool audio_pll_locked;  // stability of audio clock	RMbool lpcm_24bit;	enum EMhwlibTVStandard old_std;	enum EMhwlibTVStandard prev_std;	RMuint32 same_ct;} local_opt[2];// options->output_window needs to be set when calling this!static RMstatus init_local_options(	struct local_cmdline *options){	options->zoom_force = FALSE;	options->zoom_x = ZOOM_0;	options->zoom_y = ZOOM_0;	options->zoom_w = ZOOM_1;	options->zoom_h = ZOOM_1;	set_default_out_window(options->output_window);	options->force_overscan_crop = FALSE;	options->overscan_crop = 0;	options->overscan_crop_amount = 5;  // 2.5% on each edge. ITU Bt.1379.1 specifies 3.5% "safe action" and 5% "safe title"	options->arg_vbi = 0;	options->parse_anc = FALSE;	options->print_anc = FALSE;	options->dump_vbi = FALSE;	options->i2c_init = FALSE;	options->i2c_module = 0;	options->enable_i2c_cc = FALSE;	options->enable_i2c_wss = FALSE;	options->i2c_cc.Enable = FALSE;	options->ccfifo_print = FALSE;	options->use_soft_cc_decoder = 0;	options->ccfifo_id_in = 0;	options->ccfifo_id_send = 0;	options->ccfifo_id_out = 0;	options->ccfifo_addr_in = 0;	options->ccfifo_addr_out = 0;	options->VBIOffs = 0;	options->pVBIData = NULL;	options->vbidump = NULL;	options->update = FALSE;	options->use_gpio_fid = FALSE;	options->invert_fid = FALSE;	options->last_hotplug = FALSE;	options->pR = NULL;	options->pDmaReceive = NULL;	options->force_active_format = FALSE;	options->active_format = EMhwlibAF_same_as_picture;	options->force_wide_screen = FALSE;	options->wide_screen = FALSE;	options->wss_odd = 0;	options->wss_even = 0;	options->last_hdcp_ok = FALSE;	options->last_power = FALSE;	options->last_sync = FALSE;	options->last_clock = FALSE;	options->last_auth = FALSE;	options->last_crypt = FALSE;	options->break_hdcp = FALSE;	options->cable_eq = 0x0C;	options->last_avi.valid = FALSE;	options->new_avi = FALSE;	options->last_scan = EMhwlibScanInfo_NoData;	options->update_videomode = FALSE;	options->follow_vfreq = FALSE;	options->verbouse = FALSE;	options->intr_debug = FALSE;	options->green_bg = FALSE;	options->hdmi_mode = mode_unknown;	options->upsample_from_422 = FALSE;	options->last_isrc_header = 0;	options->last_isrc2 = FALSE;	RMMemset(options->last_isrc, 0xFF, sizeof(options->last_isrc));	options->audio_state = audio_state_off;	options->restart_audio = FALSE;	options->lpcm_24bit = FALSE;  // 16 bit	options->audio_pll_locked = TRUE;	options->same_ct = 0;		return RM_OK;}static void show_local_options(void){	fprintf(stderr, "PLAY_CAPTURE OPTIONS\n");	fprintf(stderr, "  -v: verbose (twice for more verbose)\n");	fprintf(stderr, "  -m <chip>: number of the mambo chip (default: 0)\n");	fprintf(stderr, "  -window <x> <y> <w> <h>: specify position, width and height of the scaler window\n");	fprintf(stderr, "  -zoom <x> <y> <w> <h>: zoom window into the captured video\n");	fprintf(stderr, "    all zoom values: 0..4095: absolute pixel, 4096..8192: 0%%..100%% relative size\n");	fprintf(stderr, "  -inclip <mode>: set clipping or wide mode of input: (n)ormal, (w)ide, (l)etterbox\n");	fprintf(stderr, "  -vbidump <filename>: dump received VBI data to a binary file\n");	fprintf(stderr, "  -vbiprint: print a hex-dump of the received VBI data block\n");	fprintf(stderr, "  -anc: parse VBI data for ANC header and print any Line21-CC text or TeleText\n");	fprintf(stderr, "  -ancprint: print also the ANC header info and a payload hex dump\n");	fprintf(stderr, "  -i2c <module>: which i2c module to use (0=software, 1=hardware)\n");	fprintf(stderr, "  -I <board> <port> [<dev> [<delay>]]: do i2c initialisation, defaults in []\n");	fprintf(stderr, "    chip or board:\n");	fprintf(stderr, "      [775]  (A/V-Input with saa7119, WM8775), \n");	fprintf(stderr, "      760e1  (HD Ref. w/ adv7402, MSP34x5), \n");	fprintf(stderr, "      760e2  (LCD Ref. w/ saa7119, WM8775, MSP34x5), \n");	fprintf(stderr, "      844e1  (DTV Ref. w/ saa7119, SiI9031, AD9883, WM8775, MSP34x5), \n");	fprintf(stderr, "      jamo   (KiSS Jamo plasma w/ 2 saa7119, AD9888, MSP34x5)\n");	fprintf(stderr, "      809e1  (Pioneer Video Card w/ saa7119, SiI9031, WM8738)\n");	fprintf(stderr, "    port: [cvbs1], cvbs2, svideo1, svideo2, vga, yuv1, yuv2, \n");	fprintf(stderr, "      scart1, scart2, tuner1, tuner2, hdmi0, hdmi1\n");	fprintf(stderr, "    dev: i2c device address of the video chip [0x40] (optional)\n");	fprintf(stderr, "    delay: i2c delay [0] (optional)\n");	fprintf(stderr, "  -i2ccc: enable CC passthrough from Philips 7119 via i2c\n");	fprintf(stderr, "  -i2ccc <chip>: enable CC passthrough from capture chip via i2c\n");	fprintf(stderr, "    7119: Philips SAA7119\n");	fprintf(stderr, "  -ccprint: print closed caption data from the CC fifo\n");	fprintf(stderr, "    (passing through the app instead of direct passthrough)\n");	fprintf(stderr, "  -softcc, -softcc608: enable NTSC software CC decoding on top of output picture\n");	fprintf(stderr, "  -softcc708: enable PAL software CC decoding on top of output picture\n");	fprintf(stderr, "  -i2cwss: enable WSS passthrough from Philips 7119 via i2c\n");	fprintf(stderr, "  -update: continuusly check for video mode change and adjust\n");	fprintf(stderr, "  -gpiofid: use input field ID from GPIO pin\n");	fprintf(stderr, "  -fidinv: invert detected field ID\n");	fprintf(stderr, "  -eq <len>: cable length equalisation, 0..15 [12]\n");	fprintf(stderr, "  -fv: follow the vertical frequency of the capture on the output\n");	fprintf(stderr, "  -bg: use a different background color than black\n");	fprintf(stderr, "  -ov <crop>: percentage of frame size to crop around edge for overscanned pictures [5] (applies to VGA, LVDS and digital outputs only)\n");	fprintf(stderr, "  -pcm24: capture PCM audio from I2S with 24 bits (default: 16 bits)\n");}static RMstatus parse_local_cmdline(	int argc, 	char **argv, 	int *index, 	struct local_cmdline *options){	RMstatus err = RM_OK;	int argi = *index;	RMuint32 param;	RMascii *endptr;		if (argv[argi][0] == '-') {		if (! strcmp(&(argv[argi][1]), "zoom")) {			options->zoom_force = TRUE;			SCANPARAM(options->zoom_x, "please specify a x value", 1);			SCANPARAM(options->zoom_y, "please specify a y value", 2);			SCANPARAM(options->zoom_w, "please specify a w value", 3);			SCANPARAM(options->zoom_h, "please specify a h value", 4);		}		else if (! strcmp(&(argv[argi][1]), "inclip")) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -