📄 play_capture_tw.c
字号:
(pclk == 6) ? "24 kHz <invalid>" : (pclk == 7) ? "16 kHz <invalid>" : (pclk == 8) ? "88.2 kHz" : (pclk == 9) ? "768 kHz" : (pclk == 10) ? "96 kHz" : (pclk == 11) ? "<reserved>" : (pclk == 12) ? "176.4 kHz" : (pclk == 13) ? "12 kHz <invalid>" : (pclk == 14) ? "192 kHz" : (pclk == 15) ? "<not indicated>" : "-"); // SamplingFrequency: sample rate of the audio content // SampleRate: sample rate of the audio output switch (pclk) { case 0: audio_opt->SamplingFrequency = 44100; break; case 1: audio_opt->SamplingFrequency = 0; break; // no audio case 2: audio_opt->SamplingFrequency = 48000; break; case 3: audio_opt->SamplingFrequency = 32000; break; //case 4: audio_opt->SamplingFrequency = 22050; break; //case 5: audio_opt->SamplingFrequency = 11025; break; //case 6: audio_opt->SamplingFrequency = 24000; break; //case 7: audio_opt->SamplingFrequency = 16000; break; case 8: audio_opt->SamplingFrequency = 88200; break; case 9: audio_opt->SamplingFrequency = 768000; break; case 10: audio_opt->SamplingFrequency = 96000; break; case 12: audio_opt->SamplingFrequency = 176400; break; //case 13: audio_opt->SamplingFrequency = 12000; break; case 14: audio_opt->SamplingFrequency = 192000; break; default: return RM_ERROR; } audio_opt->SampleRate = audio_opt->SamplingFrequency; // no sample rate conversion if (data[0] & 0x02) { // compressed audio fprintf(stderr, "\tAudio is compressed (assuming AC3 for now)\n"); audio_opt->auto_detect_codec = TRUE; audio_opt->Codec = AudioDecoder_Codec_AC3; audio_opt->Ac3Params.OutputChannels = Ac3_LR; } else { // PCM audio fprintf(stderr, "\tAudio is PCM\n"); audio_opt->auto_detect_codec = FALSE; audio_opt->Codec = AudioDecoder_Codec_PCM; audio_opt->SubCodec = 1; audio_opt->LpcmVobParams.ChannelAssign = LpcmVob2_LR; audio_opt->LpcmVobParams.BitsPerSample = 16; audio_opt->OutputChannels = Audio_Out_Ch_LR; } fprintf(stderr, "\n\n"); return err;}static RMstatus init_capture_SiI9031( struct RUA *pInstance, struct capture_cmdline *capture_opt, struct local_cmdline *local_opt, RMuint8 dev, RMuint8 delay){ RMstatus err; // Silicon Image 9031 setup RMuint8 i2c_data[][2] = { {0x05, 0xD0}, // end reset, enable auto reset modes {0x08, 0x05}, // start chip {0x09, 0x11}, // select input 0 {0x4A, 0x01}, // CCIR601, RGB 4:4:4 24 bit {0x49, 0x01}, // RGB input {0x48, 0x00}, // BT601 output colorspace {0x7A, 0x3F}, // ip_ctrl: initially, intr on all frames {0x88, 0x88}, // ACR1 magic value {0x89, 0x16}, // ACR2 magic value {0xB5, 0x00}, // enable auto audio control incl. I2S outputs {0xB6, 0xFF}, // enable mute conditions {0xB7, 0xFF}, // " " " {0xB8, 0x07}, // " " " {0xBB, 0x01}, // enable clear of error counts }; RMuint8 i2c_data_ext[][2] = { //{0xBF, 0x85}, // default: receive MPEG frames in MPEG area {0xBF, 0x05}, // receive ISRC1 frames in MPEG area }; if (local_opt->intr_debug) { local_opt->intr_mask[0] = 0x7F; // intr1_mask: all but acrhwcts local_opt->intr_mask[1] = 0xB9; // intr2_mask: all but vsync, gotcts, gotaud local_opt->intr_mask[2] = 0x7F; // intr3_mask: all but new_cp local_opt->intr_mask[3] = 0x7F; // intr4_mask: all local_opt->intr_mask[4] = 0xFF; // intr5_mask: all local_opt->intr_mask[5] = 0x05; // intr6_mask: all } else { local_opt->intr_mask[0] = 0x03; // intr1_mask: authstart, authdone local_opt->intr_mask[1] = 0x99; // intr2_mask: hdmimode, ckdt, scdt, vidchg //local_opt->intr_mask[2] = 0x1F; // intr3_mask: newunr, newmpeg, newaud, newspd, newavi local_opt->intr_mask[2] = 0x0F; // intr3_mask: newmpeg, newaud, newspd, newavi local_opt->intr_mask[3] = 0x1C; // intr4_mask: no_avi, cts_drop, cts_reuse local_opt->intr_mask[4] = 0xFF; // intr5_mask: fnchg, aac_mute, aul_err, vrchg, hrchg, pochg, ilchg, fschg local_opt->intr_mask[5] = 0x05; // intr6_mask: new_acp, unplug } if (local_opt->i2c_port == cap_HDMI1) { i2c_data[2][1] = 0x22; // select input 1 } // for pioneer video card (8620L/8bit/656): if (local_opt->i2c_board == cap_pioneer809e1video) { i2c_data[3][1] = 0xFB; // CCIR656, convert RGB 4:4:4 24 bit to YUV 4:2:2 8+8 bit i2c_data[5][1] = 0x01; // BT709 output colorspace } err = write_i2c(pInstance, delay, dev + 4, 0x3C, 0x01); // power up chip. err = write_i2c(pInstance, delay, dev + 4, 0x3E, 0xFF); // power up chip. err = write_i2c(pInstance, delay, dev + 4, 0x3F, 0xFF); // power up chip. err = write_i2c(pInstance, delay, dev, 0x05, 0xC3); // reset of audio FIFO and chip, put HDCP and ACR in auto-reset// err = write_i2c(pInstance, delay, dev, 0x05, 0x0F); // reset err = init_i2c(pInstance, delay, dev, i2c_data, sizeof(i2c_data) / sizeof (RMuint8) / 2); if (RMFAILED(err)) { fprintf(stderr, "Failed to init SiI9031!\n"); return err; } err = write_i2c(pInstance, delay, dev, 0x75, local_opt->intr_mask[0]); err = write_i2c(pInstance, delay, dev, 0x76, local_opt->intr_mask[1]); err = write_i2c(pInstance, delay, dev, 0x77, local_opt->intr_mask[2]); err = write_i2c(pInstance, delay, dev, 0x78, local_opt->intr_mask[3]); err = write_i2c(pInstance, delay, dev, 0x7D, local_opt->intr_mask[4]); err = write_i2c(pInstance, delay, dev, 0x7E, local_opt->intr_mask[5]); err = init_i2c(pInstance, delay, dev + 4, i2c_data_ext, sizeof(i2c_data_ext) / sizeof (RMuint8) / 2); if (RMFAILED(err)) { fprintf(stderr, "Failed to init SiI9031!\n"); return err; } init_capture_SiI9031_amclk(pInstance, dev, delay, FALSE); set_cable_comp_SiI9031(pInstance, capture_opt, local_opt, dev, delay); set_blanking_color_SiI9031(pInstance, capture_opt, local_opt, dev, delay); set_422_to_444_upsampling_SiI9031(pInstance, local_opt->upsample_from_422, dev, delay); //HCInit(); return err;}RMuint8 edid_info[0x80] = { 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x40, 0xf3, 0x11, 0x03, 0xa4, 0x0c, 0x00, 0x00, 0x0e, 0x0e, 0x01, 0x03, 0x81, 0x22, 0x1b, 0x78, 0x2a, 0x0b, 0x32, 0x9c, 0x5a, 0x4d, 0x8c, 0x26, 0x20, 0x4e, 0x57, 0xa1, 0x08, 0x00, 0x81, 0x40, 0x71, 0x4f, 0x81, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x30, 0x2a, 0x00, 0x98, 0x51, 0x00, 0x2a, 0x40, 0x30, 0x70, 0x13, 0x00, 0x52, 0x0e, 0x11, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x4c, 0x43, 0x44, 0x20, 0x31, 0x37, 0x44, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x3c, 0x3c, 0x1f, 0x40, 0x0b, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xff, 0x00, 0x57, 0x43, 0x43, 0x45, 0x31, 0x34, 0x30, 0x33, 0x32, 0x33, 0x36, 0x0a, 0x20, 0x00, 0xd8, };/* CEA 861C subset of all EMhwlib video modes */enum EMhwlibTVStandard cea861c[] = { EMhwlibTVStandard_HDMI_640x480p60, // 1 EMhwlibTVStandard_HDMI_480p60, // 2 EMhwlibTVStandard_HDMI_480p60, // 3 EMhwlibTVStandard_HDMI_720p60, // 4 EMhwlibTVStandard_HDMI_1080i60, // 5 EMhwlibTVStandard_HDMI_480i60, // 6 EMhwlibTVStandard_HDMI_480i60, // 7 EMhwlibTVStandard_HDMI_240p60, // 8 EMhwlibTVStandard_HDMI_240p60, // 9 EMhwlibTVStandard_HDMI_2880x480i60, // 10 EMhwlibTVStandard_HDMI_2880x480i60, // 11 EMhwlibTVStandard_HDMI_2880x240p60, // 12 EMhwlibTVStandard_HDMI_2880x240p60, // 13 EMhwlibTVStandard_HDMI_1440x480p60, // 14 EMhwlibTVStandard_HDMI_1440x480p60, // 15 EMhwlibTVStandard_HDMI_1080p60, // 16 EMhwlibTVStandard_HDMI_576p50, // 17 EMhwlibTVStandard_HDMI_576p50, // 18 EMhwlibTVStandard_HDMI_720p50, // 19 EMhwlibTVStandard_HDMI_1080i50, // 20 EMhwlibTVStandard_HDMI_576i50, // 21 EMhwlibTVStandard_HDMI_576i50, // 22 EMhwlibTVStandard_HDMI_288p50, // 23 EMhwlibTVStandard_HDMI_288p50, // 24 EMhwlibTVStandard_HDMI_2880x576i50, // 25 EMhwlibTVStandard_HDMI_2880x576i50, // 26 EMhwlibTVStandard_HDMI_2880x288p50, // 27 EMhwlibTVStandard_HDMI_2880x288p50, // 28 EMhwlibTVStandard_HDMI_1440x576p50, // 29 EMhwlibTVStandard_HDMI_1440x576p50, // 30 EMhwlibTVStandard_HDMI_1080p50, // 31 EMhwlibTVStandard_HDMI_1080p24, // 32 EMhwlibTVStandard_HDMI_1080p25, // 33 EMhwlibTVStandard_HDMI_1080p30, // 34 EMhwlibTVStandard_HDMI_2880x480p60, // 35 EMhwlibTVStandard_HDMI_2880x480p60, // 36 EMhwlibTVStandard_HDMI_2880x576p50, // 37 EMhwlibTVStandard_HDMI_2880x576p50, // 38 EMhwlibTVStandard_HDMI_1080i50_1250, // 39 EMhwlibTVStandard_HDMI_1080i100, // 40 EMhwlibTVStandard_HDMI_720p100, // 41 EMhwlibTVStandard_HDMI_576p100, // 42 EMhwlibTVStandard_HDMI_576p100, // 43 EMhwlibTVStandard_HDMI_576i100, // 44 EMhwlibTVStandard_HDMI_576i100, // 45 EMhwlibTVStandard_HDMI_1080i120, // 46 EMhwlibTVStandard_HDMI_720p120, // 47 EMhwlibTVStandard_HDMI_480p120, // 48 EMhwlibTVStandard_HDMI_480p120, // 49 EMhwlibTVStandard_HDMI_480i120, // 50 EMhwlibTVStandard_HDMI_480i120, // 51 EMhwlibTVStandard_HDMI_576p200, // 52 EMhwlibTVStandard_HDMI_576p200, // 53 EMhwlibTVStandard_HDMI_576i200, // 54 EMhwlibTVStandard_HDMI_576i200, // 55 EMhwlibTVStandard_HDMI_480p240, // 56 EMhwlibTVStandard_HDMI_480p240, // 57 EMhwlibTVStandard_HDMI_480i240, // 58 EMhwlibTVStandard_HDMI_480i240, // 59};/* Compare two values and return a weighted match value. Return value is 'weight' if both values are equal, or 50% of 'weight' minus the percentage points 'a' is away from 'b'. */static inline RMuint32 comp_weight(RMuint32 a, RMuint32 b, RMuint32 weight) { RMuint32 dist; if (a == b) return weight; dist = (a > b) ? a - b : b - a;// weight /= 2; dist = (dist * 100) / b; return (weight > dist) ? weight - dist : 0;}static RMascii *CEA861_ShortDescriptorVideoResolutions[] = { "Unknown", "VGA 640x480 60Hz", // 1 "480p 60Hz (4:3)", // 2 "480p 60Hz (16:9)", // 3 "720p 60Hz", // 4 "1080i 60Hz", // 5 "480i 60Hz (4:3)", // 6 "480i 60Hz (16:9)", // 7 "240p 60Hz (4:3)", // 8 "240p 60Hz (16:9)", // 9 "480i 60Hz (4:3)", // 10 "480i 60Hz (16:9)", // 11 "240p 60Hz (4:3)", // 12 "240p 60Hz (16:9)", // 13 "480p 60Hz (4:3)", // 14 "480p 60Hz (16:9)", // 15 "1080p 60Hz", // 16 "576p 50Hz (4:3)", // 17 "576p 50Hz (16:9)", // 18 "720p 50Hz", // 19 "1080i 50Hz", // 20 "576i 50Hz (4:3)", // 21 "576i 50Hz (16:9)", // 22 "288p 50Hz (4:3)", // 23 "288p 50Hz (16:9)", // 24 "576i 50Hz (4:3)", // 25 "576i 50Hz (16:9)", // 26 "288p 50Hz (4:3)", // 27 "288p 50Hz (16:9)", // 28 "576p 50Hz (4:3)", // 29 "576p 50Hz (16:9)", // 30 "1080p 50Hz", // 31 "1080p 24Hz", // 32 "1080p 25Hz", // 33 "1080p 30Hz", // 34 "480p 60Hz (4:3)", // 35 "480p 60Hz (16:9)", // 36 "576p 50Hz (4:3)", // 37 "576p 50Hz (16:9)", // 38 "1080i 50Hz", // 39 "1080i 100Hz", // 40 "720p 100Hz", // 41 "576p 100Hz (4:3)", // 42 "576p 100Hz (16:9)", // 43 "576i 100Hz (4:3)", // 44 "576i 100Hz (16:9)", // 45 "1080i 120Hz", // 46 "720p 120Hz", // 47 "480p 120Hz (4:3)", // 48 "480p 120Hz (16:9)", // 49 "480i 120Hz (4:3)", // 50 "480i 120Hz (16:9)", // 51 "576p 200Hz (4:3)", // 52 "576p 200Hz (16:9)", // 53 "576i 200Hz (4:3)", // 54 "576i 200Hz (16:9)", // 55 "480p 240Hz (4:3)", // 56 "480p 240Hz (16:9)", // 57 "480i 240Hz (4:3)", // 58 "480i 240Hz (16:9)", // 59};/* Detect video format from the line and pixel counter in the SiI9031 */static RMstatus get_format_SiI9031( struct dcc_context *dcc_info, struct capture_cmdline *options, struct local_cmdline *local_opt, RMuint8 dev, RMuint8 delay, RMbool *update){ RMstatus err; RMuint32 reg; RMuint8 data[17]; RMuint32 h_res, v_res, de_pix, de_lin, vid_vtavl, vid_vfp, vid_hfp, vid_hswidth, vid_xpcnt; RMbool intrl, vspol, hspol; RMuint32 i, best_match; enum EMhwlibTVStandard mode, old; RMascii *StandardName; RMbool limit861 = FALSE; /* whether to limit to CEA 861 modes */ if (update) *update = FALSE; old = options->TVStandard; /* read measurement registers from SiI9031 */ err = read_i2c(dcc_info->pRUA, delay, dev, 0x06, ®); if (RMFAILED(err)) return err; if ((reg & 0x03) != 0x03) { fprintf(stderr, "no %s%s%s!\n", (reg & 0x08) ? "" : "power", (reg & 0x02) ? "" : (reg & 0x08) ? "clock" : (reg & 0x01) ? " or clock" : ", clock", (reg & 0x01) ? "" : ((reg & 0x02) && (reg & 0x08)) ? "sync" : " or sync"); return RM_ERROR; } err = read_i2c_data(dcc_info->pRUA, delay, dev, 0x3A, &data[0], 4); if (RMFAILED(err)) return err; err = read_i2c_data(dcc_info->pRUA, delay, dev, 0x4E, &data[4], 8); if (RMFAILED(err)) return err; err = read_i2c_data(dcc_info->pRUA, delay, dev, 0x59, &data[12], 4); if (RMFAILED(err)) return err; err = read_i2c_data(dcc_info->pRUA, delay, dev, 0x6F, &data[16], 1); if (RMFAILED(err)) return err; h_res = (data[0] & 0xFF); h_res |= ((data[1] & 0x1F) << 8); v_res = (data[2] & 0xFF); v_res |= ((data[3] & 0x07) << 8); de_pix = (data[4] & 0xFF); de_pix |= ((data[5] & 0x1F) << 8); de_lin = (data[6] & 0xFF); de_lin |= ((data[7] & 0x07) << 8); vid_vtavl = (data[8] & 0x3F); vid_vfp = (data[9] & 0x3F); intrl = (data[11] & 0x04) ? TRUE : FALSE; vspol = (data[11] & 0x02) ? TRUE : FALSE; hspol = (data[11] & 0x01) ? TRUE : FALSE; vid_hfp = (data[12] & 0xFF); vid_hswidth = (data[14] & 0xFF); vid_hswidth |= ((data[15] & 0x03) << 8); vid_xpcnt = (data[16] & 0xFF); fprintf(stderr, "SiI9031 - %lux%lu%c, total:%lux%lu, vsync:%lu-%lu-x-%s., hsync:%lu-%lu-%lu-%s., xpcnt:%lu\n", de_pix, de_lin * (intrl ? 2 : 1), intrl ? 'i' : 'p', h_res, intrl ? v_res * 2 + 1 : v_res, vid_vfp, vid_vtavl, vspol ? "pos" : "neg", vid_hfp, vid_hswidth, h_res - de_pix - vid_hfp - vid_hswidth, hspol ? "pos" : "neg", vid_xpcnt); if (! update) return RM_OK; best_match = 0; i = limit861 ? 0 : 1; while (limit861 ? (i < (sizeof(cea861c) / sizeof(enum EMhwlibTVStandard))) : RMSUCCEEDED(GetTVStandardName((enum EMhwlibTVStandard)i, &StandardName))) { struct EMhwlibTVFormatDigital dig; RMuint32 match; RMbool dig_Intrl, dig_1001; // skip dual-aspect-ratio modes, checking for one is enough if (limit861 && (i > 0) && (cea861c[i - 1] == cea861c[i])) { i++; continue; } mode = limit861 ? cea861c[i] : (enum EMhwlibTVStandard)i; err = RUAExchangeProperty(dcc_info->pRUA, DisplayBlock, RMDisplayBlockPropertyID_TVFormatDigital,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -