Lines Matching refs:go
298 static int mjpeg_frame_header(struct go7007 *go, unsigned char *buf, int q) in mjpeg_frame_header() argument
318 buf[p++] = go->height >> 8; in mjpeg_frame_header()
319 buf[p++] = go->height & 0xff; in mjpeg_frame_header()
320 buf[p++] = go->width >> 8; in mjpeg_frame_header()
321 buf[p++] = go->width & 0xff; in mjpeg_frame_header()
373 static int gen_mjpeghdr_to_package(struct go7007 *go, __le16 *code, int space) in gen_mjpeghdr_to_package() argument
385 mjpeg_frame_header(go, buf + size, i); in gen_mjpeghdr_to_package()
388 chunk = mjpeg_frame_header(go, buf + size, 1); in gen_mjpeghdr_to_package()
424 static int mpeg1_frame_header(struct go7007 *go, unsigned char *buf, in mpeg1_frame_header() argument
428 int rows = go->interlace_coding ? go->height / 32 : go->height / 16; in mpeg1_frame_header()
455 CODE_ADD(c, go->format == V4L2_PIX_FMT_MPEG2 ? 0x7 : 0x4, 4); in mpeg1_frame_header()
457 CODE_ADD(c, go->format == V4L2_PIX_FMT_MPEG2 ? 0x7 : 0x4, 4); in mpeg1_frame_header()
466 if (go->format == V4L2_PIX_FMT_MPEG2) { in mpeg1_frame_header()
471 if (go->interlace_coding) { in mpeg1_frame_header()
473 if (go->dvd_mode) in mpeg1_frame_header()
493 if (go->interlace_coding) { in mpeg1_frame_header()
499 if (go->interlace_coding) in mpeg1_frame_header()
503 for (j = (go->width >> 4) - 2; j >= 33; j -= 33) in mpeg1_frame_header()
507 if (go->interlace_coding) { in mpeg1_frame_header()
513 if (go->interlace_coding) in mpeg1_frame_header()
532 static int mpeg1_sequence_header(struct go7007 *go, unsigned char *buf, int ext) in mpeg1_sequence_header() argument
537 if (go->format == V4L2_PIX_FMT_MPEG1) { in mpeg1_sequence_header()
538 switch (go->aspect_ratio) { in mpeg1_sequence_header()
540 aspect_ratio = go->standard == GO7007_STD_NTSC ? 3 : 2; in mpeg1_sequence_header()
543 aspect_ratio = go->standard == GO7007_STD_NTSC ? 5 : 4; in mpeg1_sequence_header()
550 switch (go->aspect_ratio) { in mpeg1_sequence_header()
562 switch (go->sensor_framerate) { in mpeg1_sequence_header()
570 picture_rate = go->interlace_coding ? 6 : 3; in mpeg1_sequence_header()
573 picture_rate = go->interlace_coding ? 7 : 4; in mpeg1_sequence_header()
576 picture_rate = go->interlace_coding ? 8 : 5; in mpeg1_sequence_header()
583 CODE_ADD(c, go->width, 12); in mpeg1_sequence_header()
584 CODE_ADD(c, go->height, 12); in mpeg1_sequence_header()
587 CODE_ADD(c, go->format == V4L2_PIX_FMT_MPEG2 ? 20000 : 0x3ffff, 18); in mpeg1_sequence_header()
589 CODE_ADD(c, go->format == V4L2_PIX_FMT_MPEG2 ? 112 : 20, 10); in mpeg1_sequence_header()
597 if (go->format == V4L2_PIX_FMT_MPEG2) { in mpeg1_sequence_header()
601 if (go->interlace_coding) in mpeg1_sequence_header()
615 CODE_ADD(c, go->standard == GO7007_STD_NTSC ? 2 : 1, 3); in mpeg1_sequence_header()
618 CODE_ADD(c, go->width, 14); in mpeg1_sequence_header()
620 CODE_ADD(c, go->height, 14); in mpeg1_sequence_header()
639 static int gen_mpeg1hdr_to_package(struct go7007 *go, in gen_mpeg1hdr_to_package() argument
651 framelen[0] = mpeg1_frame_header(go, buf, 0, 1, PFRAME); in gen_mpeg1hdr_to_package()
652 if (go->interlace_coding) in gen_mpeg1hdr_to_package()
653 framelen[0] += mpeg1_frame_header(go, buf + framelen[0] / 8, in gen_mpeg1hdr_to_package()
658 framelen[1] = mpeg1_frame_header(go, buf + i, 0, 1, BFRAME_PRE); in gen_mpeg1hdr_to_package()
659 if (go->interlace_coding) in gen_mpeg1hdr_to_package()
660 framelen[1] += mpeg1_frame_header(go, buf + i + framelen[1] / 8, in gen_mpeg1hdr_to_package()
665 framelen[2] = mpeg1_frame_header(go, buf + i, 0, 1, BFRAME_POST); in gen_mpeg1hdr_to_package()
666 if (go->interlace_coding) in gen_mpeg1hdr_to_package()
667 framelen[2] += mpeg1_frame_header(go, buf + i + framelen[2] / 8, in gen_mpeg1hdr_to_package()
672 framelen[3] = mpeg1_frame_header(go, buf + i, 0, 1, BFRAME_BIDIR); in gen_mpeg1hdr_to_package()
673 if (go->interlace_coding) in gen_mpeg1hdr_to_package()
674 framelen[3] += mpeg1_frame_header(go, buf + i + framelen[3] / 8, in gen_mpeg1hdr_to_package()
679 mpeg1_sequence_header(go, buf + i, 0); in gen_mpeg1hdr_to_package()
716 static int vti_bitlen(struct go7007 *go) in vti_bitlen() argument
718 unsigned int i, max_time_incr = go->sensor_framerate / go->fps_scale; in vti_bitlen()
725 static int mpeg4_frame_header(struct go7007 *go, unsigned char *buf, in mpeg4_frame_header() argument
730 int mb_count = (go->width >> 4) * (go->height >> 4); in mpeg4_frame_header()
736 CODE_ADD(c, 0, vti_bitlen(go)); in mpeg4_frame_header()
779 static int mpeg4_sequence_header(struct go7007 *go, unsigned char *buf, int ext) in mpeg4_sequence_header() argument
781 const unsigned char head[] = { 0x00, 0x00, 0x01, 0xb0, go->pali, in mpeg4_sequence_header()
786 int fps = go->sensor_framerate / go->fps_scale; in mpeg4_sequence_header()
789 switch (go->aspect_ratio) { in mpeg4_sequence_header()
791 aspect_ratio = go->standard == GO7007_STD_NTSC ? 3 : 2; in mpeg4_sequence_header()
794 aspect_ratio = go->standard == GO7007_STD_NTSC ? 5 : 4; in mpeg4_sequence_header()
807 CODE_ADD(c, 1001, vti_bitlen(go)); in mpeg4_sequence_header()
809 CODE_ADD(c, go->width, 13); in mpeg4_sequence_header()
811 CODE_ADD(c, go->height, 13); in mpeg4_sequence_header()
825 static int gen_mpeg4hdr_to_package(struct go7007 *go, in gen_mpeg4hdr_to_package() argument
837 framelen[0] = mpeg4_frame_header(go, buf, 0, PFRAME); in gen_mpeg4hdr_to_package()
839 framelen[1] = mpeg4_frame_header(go, buf + i, 0, BFRAME_PRE); in gen_mpeg4hdr_to_package()
841 framelen[2] = mpeg4_frame_header(go, buf + i, 0, BFRAME_POST); in gen_mpeg4hdr_to_package()
843 framelen[3] = mpeg4_frame_header(go, buf + i, 0, BFRAME_BIDIR); in gen_mpeg4hdr_to_package()
845 mpeg4_frame_header(go, buf + i, 0, BFRAME_EMPTY); in gen_mpeg4hdr_to_package()
847 mpeg4_sequence_header(go, buf + i, 0); in gen_mpeg4hdr_to_package()
880 addr = go->ipb ? 0x14f9 : 0x0af9; in gen_mpeg4hdr_to_package()
882 framelen[4] = mpeg4_frame_header(go, buf, 1, PFRAME); in gen_mpeg4hdr_to_package()
884 framelen[5] = mpeg4_frame_header(go, buf + i, 1, BFRAME_PRE); in gen_mpeg4hdr_to_package()
886 framelen[6] = mpeg4_frame_header(go, buf + i, 1, BFRAME_POST); in gen_mpeg4hdr_to_package()
888 framelen[7] = mpeg4_frame_header(go, buf + i, 1, BFRAME_BIDIR); in gen_mpeg4hdr_to_package()
890 mpeg4_frame_header(go, buf + i, 1, BFRAME_EMPTY); in gen_mpeg4hdr_to_package()
927 static int brctrl_to_package(struct go7007 *go, in brctrl_to_package() argument
931 int lambda = (go->format == V4L2_PIX_FMT_MJPEG || go->dvd_mode) ? in brctrl_to_package()
933 int peak_rate = 6 * go->bitrate / 5; in brctrl_to_package()
934 int vbv_buffer = go->format == V4L2_PIX_FMT_MJPEG ? in brctrl_to_package()
935 go->bitrate : in brctrl_to_package()
936 (go->dvd_mode ? 900000 : peak_rate); in brctrl_to_package()
937 int fps = go->sensor_framerate / go->fps_scale; in brctrl_to_package()
940 u32 sgop_expt_addr = go->bitrate / 32 * (go->ipb ? 3 : 1) * 1001 / fps; in brctrl_to_package()
942 u32 total_expt_addr = go->bitrate / 32 * 1000 / fps * (fps / 1000); in brctrl_to_package()
946 2 * go->width * go->height * (go->ipb ? 6 : 4) / 32, in brctrl_to_package()
948 2 * go->width * go->height * (go->ipb ? 6 : 4) / 32, in brctrl_to_package()
950 2 * go->width * go->height * (go->ipb ? 6 : 4) / 32, in brctrl_to_package()
952 2 * go->width * go->height * (go->ipb ? 6 : 4) / 32, in brctrl_to_package()
957 0xBF20, go->ipb ? converge_speed_ipb[converge_speed] in brctrl_to_package()
959 0xBF21, go->ipb ? 2 : 0, in brctrl_to_package()
960 0xBF22, go->ipb ? LAMBDA_table[0][lambda / 2 + 50] in brctrl_to_package()
962 0xBF23, go->ipb ? LAMBDA_table[1][lambda] : 32767, in brctrl_to_package()
1016 0xBF46, (go->width >> 4) * (go->height >> 4), in brctrl_to_package()
1084 static int config_package(struct go7007 *go, __le16 *code, int space) in config_package() argument
1086 int fps = go->sensor_framerate / go->fps_scale / 1000; in config_package()
1087 int rows = go->interlace_coding ? go->height / 32 : go->height / 16; in config_package()
1097 0xc6c3, go->format == V4L2_PIX_FMT_MPEG4 ? 0 : in config_package()
1098 (go->format == V4L2_PIX_FMT_H263 ? 0 : 1), in config_package()
1099 0xc680, go->format == V4L2_PIX_FMT_MPEG4 ? 0xf1 : in config_package()
1100 (go->format == V4L2_PIX_FMT_H263 ? 0x61 : in config_package()
1115 0xd472, (go->board_info->sensor_flags & in config_package()
1117 (!go->interlace_coding) ? in config_package()
1119 0xd475, (go->board_info->sensor_flags & in config_package()
1121 (!go->interlace_coding) ? in config_package()
1123 0xc404, go->interlace_coding ? 0x44 : in config_package()
1124 (go->format == V4L2_PIX_FMT_MPEG4 ? 0x11 : in config_package()
1125 (go->format == V4L2_PIX_FMT_MPEG1 ? 0x02 : in config_package()
1126 (go->format == V4L2_PIX_FMT_MPEG2 ? 0x04 : in config_package()
1127 (go->format == V4L2_PIX_FMT_H263 ? 0x08 : in config_package()
1129 0xbf0a, (go->format == V4L2_PIX_FMT_MPEG4 ? 8 : in config_package()
1130 (go->format == V4L2_PIX_FMT_MPEG1 ? 1 : in config_package()
1131 (go->format == V4L2_PIX_FMT_MPEG2 ? 2 : in config_package()
1132 (go->format == V4L2_PIX_FMT_H263 ? 4 : 16)))) | in config_package()
1133 ((go->repeat_seqhead ? 1 : 0) << 6) | in config_package()
1134 ((go->dvd_mode ? 1 : 0) << 9) | in config_package()
1135 ((go->gop_header_enable ? 1 : 0) << 10), in config_package()
1137 0xdd5a, go->ipb ? 0x14 : 0x0a, in config_package()
1141 0xc40a, (go->width << 4) | rows, in config_package()
1142 0xe01a, go->board_info->hpi_buffer_cap, in config_package()
1171 0xbfe3, go->ipb ? 3 : 1, in config_package()
1172 0xc031, go->board_info->sensor_flags & in config_package()
1177 0xdd88, go->ipb ? 0x1401 : 0x0a01, in config_package()
1178 0xdd90, go->ipb ? 0x1401 : 0x0a01, in config_package()
1190 0xbfec, (go->interlace_coding ? 1 << 15 : 0) | in config_package()
1191 (go->modet_enable ? 0xa : 0) | in config_package()
1192 (go->board_info->sensor_flags & in config_package()
1197 0xbff0, go->board_info->sensor_flags & in config_package()
1206 static int seqhead_to_package(struct go7007 *go, __le16 *code, int space, in seqhead_to_package() argument
1207 int (*sequence_header_func)(struct go7007 *go, in seqhead_to_package() argument
1210 int vop_time_increment_bitlength = vti_bitlen(go); in seqhead_to_package()
1211 int fps = go->sensor_framerate / go->fps_scale * in seqhead_to_package()
1212 (go->interlace_coding ? 2 : 1); in seqhead_to_package()
1214 int len = sequence_header_func(go, buf, 1); in seqhead_to_package()
1285 static int avsync_to_package(struct go7007 *go, __le16 *code, int space) in avsync_to_package() argument
1287 int arate = go->board_info->audio_rate * 1001 * go->fps_scale; in avsync_to_package()
1288 int ratio = arate / go->sensor_framerate; in avsync_to_package()
1290 int rprime = relative_prime(go->sensor_framerate, in avsync_to_package()
1291 arate % go->sensor_framerate); in avsync_to_package()
1292 int f1 = (arate % go->sensor_framerate) / rprime; in avsync_to_package()
1293 int f2 = (go->sensor_framerate - arate % go->sensor_framerate) / rprime; in avsync_to_package()
1316 static int final_package(struct go7007 *go, __le16 *code, int space) in final_package() argument
1318 int rows = go->interlace_coding ? go->height / 32 : go->height / 16; in final_package()
1328 ((go->board_info->sensor_flags & GO7007_SENSOR_TV) && in final_package()
1329 (!go->interlace_coding) ? in final_package()
1331 ((go->encoder_subsample ? 1 : 0) << 8) | in final_package()
1332 (go->board_info->sensor_flags & in final_package()
1334 ((go->encoder_v_halve ? 1 : 0) << 14) | in final_package()
1335 (go->encoder_v_halve ? rows << 9 : rows << 8) | in final_package()
1336 (go->encoder_h_halve ? 1 << 6 : 0) | in final_package()
1337 (go->encoder_h_halve ? go->width >> 3 : go->width >> 4), in final_package()
1338 (1 << 15) | (go->encoder_v_offset << 6) | in final_package()
1339 (1 << 7) | (go->encoder_h_offset >> 2), in final_package()
1343 ((go->fps_scale - 1) << 8) | in final_package()
1344 (go->board_info->sensor_flags & GO7007_SENSOR_TV ? in final_package()
1347 go->ipb ? 0xd4c : 0x36b, in final_package()
1348 (rows << 8) | (go->width >> 4), in final_package()
1349 go->format == V4L2_PIX_FMT_MPEG4 ? 0x0404 : 0, in final_package()
1350 (1 << 15) | ((go->interlace_coding ? 1 : 0) << 13) | in final_package()
1351 ((go->closed_gop ? 1 : 0) << 12) | in final_package()
1352 ((go->format == V4L2_PIX_FMT_MPEG4 ? 1 : 0) << 11) | in final_package()
1354 ((go->ipb ? 3 : 0) << 7) | in final_package()
1355 ((go->modet_enable ? 1 : 0) << 2) | in final_package()
1356 ((go->dvd_mode ? 1 : 0) << 1) | 1, in final_package()
1357 (go->format == V4L2_PIX_FMT_MPEG1 ? 0x89a0 : in final_package()
1358 (go->format == V4L2_PIX_FMT_MPEG2 ? 0x89a0 : in final_package()
1359 (go->format == V4L2_PIX_FMT_MJPEG ? 0x89a0 : in final_package()
1360 (go->format == V4L2_PIX_FMT_MPEG4 ? 0x8920 : in final_package()
1361 (go->format == V4L2_PIX_FMT_H263 ? 0x8920 : 0))))), in final_package()
1362 go->ipb ? 0x1f15 : 0x1f0b, in final_package()
1363 go->ipb ? 0x0015 : 0x000b, in final_package()
1364 go->ipb ? 0xa800 : 0x5800, in final_package()
1372 go->ipb ? (go->gop_size / 3) : go->gop_size, in final_package()
1373 (go->height >> 4) * (go->width >> 4) * 110 / 100, in final_package()
1379 static int audio_to_package(struct go7007 *go, __le16 *code, int space) in audio_to_package() argument
1381 int clock_config = ((go->board_info->audio_flags & in audio_to_package()
1383 ((go->board_info->audio_flags & in audio_to_package()
1385 (((go->board_info->audio_bclk_div / 4) - 1) << 4) | in audio_to_package()
1386 (go->board_info->audio_main_div - 1); in audio_to_package()
1400 0x9001, (go->board_info->audio_flags & 0xffff) | in audio_to_package()
1402 0x9000, ((go->board_info->audio_flags & in audio_to_package()
1429 static int modet_to_package(struct go7007 *go, __le16 *code, int space) in modet_to_package() argument
1431 bool has_modet0 = go->modet[0].enable; in modet_to_package()
1432 bool has_modet1 = go->modet[1].enable; in modet_to_package()
1433 bool has_modet2 = go->modet[2].enable; in modet_to_package()
1434 bool has_modet3 = go->modet[3].enable; in modet_to_package()
1439 0xbf82, has_modet0 ? go->modet[0].pixel_threshold : 32767, in modet_to_package()
1440 0xbf83, has_modet1 ? go->modet[1].pixel_threshold : 32767, in modet_to_package()
1441 0xbf84, has_modet2 ? go->modet[2].pixel_threshold : 32767, in modet_to_package()
1442 0xbf85, has_modet3 ? go->modet[3].pixel_threshold : 32767, in modet_to_package()
1443 0xbf86, has_modet0 ? go->modet[0].motion_threshold : 32767, in modet_to_package()
1444 0xbf87, has_modet1 ? go->modet[1].motion_threshold : 32767, in modet_to_package()
1445 0xbf88, has_modet2 ? go->modet[2].motion_threshold : 32767, in modet_to_package()
1446 0xbf89, has_modet3 ? go->modet[3].motion_threshold : 32767, in modet_to_package()
1447 0xbf8a, has_modet0 ? go->modet[0].mb_threshold : 32767, in modet_to_package()
1448 0xbf8b, has_modet1 ? go->modet[1].mb_threshold : 32767, in modet_to_package()
1449 0xbf8c, has_modet2 ? go->modet[2].mb_threshold : 32767, in modet_to_package()
1450 0xbf8d, has_modet3 ? go->modet[3].mb_threshold : 32767, in modet_to_package()
1466 pack[i * 2 + 3] |= go->modet_map[mb]; in modet_to_package()
1502 static int do_special(struct go7007 *go, u16 type, __le16 *code, int space, in do_special() argument
1507 switch (go->format) { in do_special()
1509 return gen_mjpeghdr_to_package(go, code, space); in do_special()
1512 return gen_mpeg1hdr_to_package(go, code, space, in do_special()
1515 return gen_mpeg4hdr_to_package(go, code, space, in do_special()
1519 return brctrl_to_package(go, code, space, framelen); in do_special()
1521 return config_package(go, code, space); in do_special()
1523 switch (go->format) { in do_special()
1526 return seqhead_to_package(go, code, space, in do_special()
1529 return seqhead_to_package(go, code, space, in do_special()
1535 return avsync_to_package(go, code, space); in do_special()
1537 return final_package(go, code, space); in do_special()
1539 return audio_to_package(go, code, space); in do_special()
1541 return modet_to_package(go, code, space); in do_special()
1543 dev_err(go->dev, in do_special()
1548 int go7007_construct_fw_image(struct go7007 *go, u8 **fw, int *fwlen) in go7007_construct_fw_image() argument
1557 switch (go->format) { in go7007_construct_fw_image()
1573 if (request_firmware(&fw_entry, GO7007_FW_NAME, go->dev)) { in go7007_construct_fw_image()
1574 dev_err(go->dev, in go7007_construct_fw_image()
1589 dev_err(go->dev, in go7007_construct_fw_image()
1596 ret = do_special(go, __le16_to_cpu(src[2]), in go7007_construct_fw_image()
1599 dev_err(go->dev, in go7007_construct_fw_image()
1606 dev_err(go->dev, in go7007_construct_fw_image()