Skip to content

Commit 4798d7a

Browse files
committed
Fixed crop at 1X
1 parent 7606c76 commit 4798d7a

1 file changed

Lines changed: 57 additions & 10 deletions

File tree

GBSC-Pro-Source code/usart_uart_dma/usb_dev_cdc/source/videoprocess.c

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,13 @@ uint8_t buff_send[APP_FRAME_LEN_MAX];
2929
uint8_t I2C_COMMANDS_I2P_ON[] =
3030
{
3131
0x84,0x55,0x80, // ADV7280 - I2C_DEINT_ENABLE: Enable I2P Converter
32-
0x84,0x5B,0x80, // ADV7280 - ADV_TIMING_MODE_EN: Disable advanced timing mode
32+
0x84,0x5B,0x00, // ADV7280 - ADV_TIMING_MODE_EN: Disable advanced timing mode
3333
0x84,0x5A,0x02, // ADV7280 - Not documented on page 99 - Configure I2P Parameters Smooth 1A (?)
34-
0x42,0x0E,0x40, // ADV7280 - ADI Control 1: User Sub Map 2
35-
0x42,0xE0,0x01, // ADV7280 - FL Control: Enables fast lock mode
36-
0x42,0x0E,0x00, // ADV7280 - ADI Control 1: main register
3734
};
3835

3936
// I2C_COMMANDS_I2P_OFF_p
4037
// I2C_COMMANDS_I2P_OFF_240p
4138
const uint8_t I2C_COMMANDS_I2P_OFF_p[] = {
42-
0x42,0x0E,0x40, // ADV7280 - ADI Control 1: User Sub Map 2
43-
0x42,0xE0,0x01, // ADV7280 - FL Control: Enables fast lock mode
44-
0x42,0x0E,0x00, // ADV7280 - ADI Control 1: main register
4539
0x84,0x55,0x00, // ADV7280 - I2C_DEINT_ENABLE: Disable I2P Converter
4640
0x84,0x5B,0x00, // ADV7280 - ADV_TIMING_MODE_EN: Enable advanced timing mode
4741
0x84,0x5A,0x02, // ADV7280 - Not documented on page 99 - Configure I2P Parameters Smooth 1A (?)
@@ -168,9 +162,6 @@ uint8_t I2C_AUTO_COMMANDS[] =
168162
0x42,0x0E,0x80, // ADV7280 - ADI Required Write
169163
0x42,0xD9,0x44, // ADV7280 - ADI Required Write
170164
0x42,0x0E,0x00, // ADV7280 - ADI Control 1: main register
171-
0x42,0x0E,0x40, // ADV7280 - ADI Control 1: User Sub Map 2
172-
0x42,0xE0,0x01, // ADV7280 - FL Control: Enables fast lock mode
173-
0x42,0x0E,0x00, // ADV7280 - ADI Control 1: main register
174165

175166
// Enable I2P
176167
0x42,0xFD,0x84, // ADV7280 - set the VPP address to 0x84
@@ -207,6 +198,59 @@ uint8_t Ace_Code_OFF[] =
207198
0x42,0x0E,0x00 // ADV7280 - ADI Control 1: main register
208199
};
209200

201+
// 525p Encoder Configuration
202+
uint8_t I2C_COMMANDS_525p_CONFIG[] = {
203+
0x56,0x30,0x04,
204+
0x56,0x31,0x11,
205+
};
206+
207+
// 625p Encoder Configuration
208+
uint8_t I2C_COMMANDS_625p_CONFIG[] = {
209+
0x56,0x30,0x1C,
210+
0x56,0x31,0x11,
211+
};
212+
213+
// Function to configure video encoder
214+
void configure_video_encoder()
215+
{
216+
// Extract bits [6:5:4] for AD_RESULT
217+
uint8_t ad_result;
218+
uint8_t buff[1] = { 0x10 };
219+
Chip_Receive(DEVICE_ADDR, &buff[0], &ad_result, 1, TIMEOUT);
220+
221+
uint8_t ad_standard = (ad_result & 0x70) >> 4;
222+
uint8_t is_525p = 0;
223+
224+
// Determine if it's 525p or 625p
225+
// AD_RESULT values:
226+
// 0: NTSC M/NTSC J (525p)
227+
// 1: NTSC 4.43 (525p)
228+
// 2: PAL M (525p)
229+
// 3: PAL 60 (525p)
230+
// 4: PAL B/PAL G/PAL H/PAL I/PAL D (625p)
231+
// 5: SECAM (625p)
232+
// 6: PAL Combination N (625p)
233+
// 7: SECAM 525 (525p)
234+
235+
if (ad_standard == 0 || ad_standard == 1 || ad_standard == 2 || ad_standard == 3 || ad_standard == 7) {
236+
is_525p = 1; // 525p
237+
} else {
238+
is_525p = 0; // 625p
239+
}
240+
241+
if (is_525p) {
242+
// Send 525p configuration
243+
(void)ADV_7280_Send_Buff(I2C_COMMANDS_525p_CONFIG, sizeof(I2C_COMMANDS_525p_CONFIG) / 3, TIMEOUT);
244+
printf("525p format configured\n");
245+
}
246+
247+
if (!is_525p) {
248+
// Send 625p configuration
249+
(void)ADV_7280_Send_Buff(I2C_COMMANDS_625p_CONFIG, sizeof(I2C_COMMANDS_625p_CONFIG) / 3, TIMEOUT);
250+
printf("625p format configured\n");
251+
}
252+
}
253+
210254
void video_init(void)
211255
{
212256
uint8_t count = 0;
@@ -231,7 +275,10 @@ void video_init(void)
231275
printf(" Init adv_tv: 0x%02x", adv_tv);
232276
(void)I2C_Master_Transmit(DEVICE_ADDR, buff, 2, TIMEOUT); // mode
233277

278+
// Configure video encoder based on detection
279+
configure_video_encoder();
234280
set_bcsh();
281+
235282
if (adv_double)
236283
{
237284
set_double_line(adv_double); // GPIO_ReadInputPins(GPIO_PORT_B,GPIO_PIN_05)

0 commit comments

Comments
 (0)