Lines Matching refs:go

290 static int mjpeg_frame_header(struct go7007 *go, unsigned char *buf, int q)  in mjpeg_frame_header()  argument
310 buf[p++] = go->height >> 8; in mjpeg_frame_header()
311 buf[p++] = go->height & 0xff; in mjpeg_frame_header()
312 buf[p++] = go->width >> 8; in mjpeg_frame_header()
313 buf[p++] = go->width & 0xff; in mjpeg_frame_header()
365 static int gen_mjpeghdr_to_package(struct go7007 *go, __le16 *code, int space) in gen_mjpeghdr_to_package() argument
377 mjpeg_frame_header(go, buf + size, i); in gen_mjpeghdr_to_package()
380 chunk = mjpeg_frame_header(go, buf + size, 1); in gen_mjpeghdr_to_package()
416 static int mpeg1_frame_header(struct go7007 *go, unsigned char *buf, in mpeg1_frame_header() argument
420 int rows = go->interlace_coding ? go->height / 32 : go->height / 16; in mpeg1_frame_header()
447 CODE_ADD(c, go->format == V4L2_PIX_FMT_MPEG2 ? 0x7 : 0x4, 4); in mpeg1_frame_header()
449 CODE_ADD(c, go->format == V4L2_PIX_FMT_MPEG2 ? 0x7 : 0x4, 4); in mpeg1_frame_header()
458 if (go->format == V4L2_PIX_FMT_MPEG2) { in mpeg1_frame_header()
463 if (go->interlace_coding) { in mpeg1_frame_header()
465 if (go->dvd_mode) in mpeg1_frame_header()
485 if (go->interlace_coding) { in mpeg1_frame_header()
491 if (go->interlace_coding) in mpeg1_frame_header()
495 for (j = (go->width >> 4) - 2; j >= 33; j -= 33) in mpeg1_frame_header()
499 if (go->interlace_coding) { in mpeg1_frame_header()
505 if (go->interlace_coding) in mpeg1_frame_header()
524 static int mpeg1_sequence_header(struct go7007 *go, unsigned char *buf, int ext) in mpeg1_sequence_header() argument
529 if (go->format == V4L2_PIX_FMT_MPEG1) { in mpeg1_sequence_header()
530 switch (go->aspect_ratio) { in mpeg1_sequence_header()
532 aspect_ratio = go->standard == GO7007_STD_NTSC ? 3 : 2; in mpeg1_sequence_header()
535 aspect_ratio = go->standard == GO7007_STD_NTSC ? 5 : 4; in mpeg1_sequence_header()
542 switch (go->aspect_ratio) { in mpeg1_sequence_header()
554 switch (go->sensor_framerate) { in mpeg1_sequence_header()
562 picture_rate = go->interlace_coding ? 6 : 3; in mpeg1_sequence_header()
565 picture_rate = go->interlace_coding ? 7 : 4; in mpeg1_sequence_header()
568 picture_rate = go->interlace_coding ? 8 : 5; in mpeg1_sequence_header()
575 CODE_ADD(c, go->width, 12); in mpeg1_sequence_header()
576 CODE_ADD(c, go->height, 12); in mpeg1_sequence_header()
579 CODE_ADD(c, go->format == V4L2_PIX_FMT_MPEG2 ? 20000 : 0x3ffff, 18); in mpeg1_sequence_header()
581 CODE_ADD(c, go->format == V4L2_PIX_FMT_MPEG2 ? 112 : 20, 10); in mpeg1_sequence_header()
589 if (go->format == V4L2_PIX_FMT_MPEG2) { in mpeg1_sequence_header()
593 if (go->interlace_coding) in mpeg1_sequence_header()
607 CODE_ADD(c, go->standard == GO7007_STD_NTSC ? 2 : 1, 3); in mpeg1_sequence_header()
610 CODE_ADD(c, go->width, 14); in mpeg1_sequence_header()
612 CODE_ADD(c, go->height, 14); in mpeg1_sequence_header()
631 static int gen_mpeg1hdr_to_package(struct go7007 *go, in gen_mpeg1hdr_to_package() argument
643 framelen[0] = mpeg1_frame_header(go, buf, 0, 1, PFRAME); in gen_mpeg1hdr_to_package()
644 if (go->interlace_coding) in gen_mpeg1hdr_to_package()
645 framelen[0] += mpeg1_frame_header(go, buf + framelen[0] / 8, in gen_mpeg1hdr_to_package()
650 framelen[1] = mpeg1_frame_header(go, buf + i, 0, 1, BFRAME_PRE); in gen_mpeg1hdr_to_package()
651 if (go->interlace_coding) in gen_mpeg1hdr_to_package()
652 framelen[1] += mpeg1_frame_header(go, buf + i + framelen[1] / 8, in gen_mpeg1hdr_to_package()
657 framelen[2] = mpeg1_frame_header(go, buf + i, 0, 1, BFRAME_POST); in gen_mpeg1hdr_to_package()
658 if (go->interlace_coding) in gen_mpeg1hdr_to_package()
659 framelen[2] += mpeg1_frame_header(go, buf + i + framelen[2] / 8, in gen_mpeg1hdr_to_package()
664 framelen[3] = mpeg1_frame_header(go, buf + i, 0, 1, BFRAME_BIDIR); in gen_mpeg1hdr_to_package()
665 if (go->interlace_coding) in gen_mpeg1hdr_to_package()
666 framelen[3] += mpeg1_frame_header(go, buf + i + framelen[3] / 8, in gen_mpeg1hdr_to_package()
671 mpeg1_sequence_header(go, buf + i, 0); in gen_mpeg1hdr_to_package()
708 static int vti_bitlen(struct go7007 *go) in vti_bitlen() argument
710 unsigned int i, max_time_incr = go->sensor_framerate / go->fps_scale; in vti_bitlen()
717 static int mpeg4_frame_header(struct go7007 *go, unsigned char *buf, in mpeg4_frame_header() argument
722 int mb_count = (go->width >> 4) * (go->height >> 4); in mpeg4_frame_header()
728 CODE_ADD(c, 0, vti_bitlen(go)); in mpeg4_frame_header()
771 static int mpeg4_sequence_header(struct go7007 *go, unsigned char *buf, int ext) in mpeg4_sequence_header() argument
773 const unsigned char head[] = { 0x00, 0x00, 0x01, 0xb0, go->pali, in mpeg4_sequence_header()
778 int fps = go->sensor_framerate / go->fps_scale; in mpeg4_sequence_header()
781 switch (go->aspect_ratio) { in mpeg4_sequence_header()
783 aspect_ratio = go->standard == GO7007_STD_NTSC ? 3 : 2; in mpeg4_sequence_header()
786 aspect_ratio = go->standard == GO7007_STD_NTSC ? 5 : 4; in mpeg4_sequence_header()
799 CODE_ADD(c, 1001, vti_bitlen(go)); in mpeg4_sequence_header()
801 CODE_ADD(c, go->width, 13); in mpeg4_sequence_header()
803 CODE_ADD(c, go->height, 13); in mpeg4_sequence_header()
817 static int gen_mpeg4hdr_to_package(struct go7007 *go, in gen_mpeg4hdr_to_package() argument
829 framelen[0] = mpeg4_frame_header(go, buf, 0, PFRAME); in gen_mpeg4hdr_to_package()
831 framelen[1] = mpeg4_frame_header(go, buf + i, 0, BFRAME_PRE); in gen_mpeg4hdr_to_package()
833 framelen[2] = mpeg4_frame_header(go, buf + i, 0, BFRAME_POST); in gen_mpeg4hdr_to_package()
835 framelen[3] = mpeg4_frame_header(go, buf + i, 0, BFRAME_BIDIR); in gen_mpeg4hdr_to_package()
837 mpeg4_frame_header(go, buf + i, 0, BFRAME_EMPTY); in gen_mpeg4hdr_to_package()
839 mpeg4_sequence_header(go, buf + i, 0); in gen_mpeg4hdr_to_package()
872 addr = go->ipb ? 0x14f9 : 0x0af9; in gen_mpeg4hdr_to_package()
874 framelen[4] = mpeg4_frame_header(go, buf, 1, PFRAME); in gen_mpeg4hdr_to_package()
876 framelen[5] = mpeg4_frame_header(go, buf + i, 1, BFRAME_PRE); in gen_mpeg4hdr_to_package()
878 framelen[6] = mpeg4_frame_header(go, buf + i, 1, BFRAME_POST); in gen_mpeg4hdr_to_package()
880 framelen[7] = mpeg4_frame_header(go, buf + i, 1, BFRAME_BIDIR); in gen_mpeg4hdr_to_package()
882 mpeg4_frame_header(go, buf + i, 1, BFRAME_EMPTY); in gen_mpeg4hdr_to_package()
919 static int brctrl_to_package(struct go7007 *go, in brctrl_to_package() argument
923 int lambda = (go->format == V4L2_PIX_FMT_MJPEG || go->dvd_mode) ? in brctrl_to_package()
925 int peak_rate = 6 * go->bitrate / 5; in brctrl_to_package()
926 int vbv_buffer = go->format == V4L2_PIX_FMT_MJPEG ? in brctrl_to_package()
927 go->bitrate : in brctrl_to_package()
928 (go->dvd_mode ? 900000 : peak_rate); in brctrl_to_package()
929 int fps = go->sensor_framerate / go->fps_scale; in brctrl_to_package()
932 u32 sgop_expt_addr = go->bitrate / 32 * (go->ipb ? 3 : 1) * 1001 / fps; in brctrl_to_package()
934 u32 total_expt_addr = go->bitrate / 32 * 1000 / fps * (fps / 1000); in brctrl_to_package()
938 2 * go->width * go->height * (go->ipb ? 6 : 4) / 32, in brctrl_to_package()
940 2 * go->width * go->height * (go->ipb ? 6 : 4) / 32, in brctrl_to_package()
942 2 * go->width * go->height * (go->ipb ? 6 : 4) / 32, in brctrl_to_package()
944 2 * go->width * go->height * (go->ipb ? 6 : 4) / 32, in brctrl_to_package()
949 0xBF20, go->ipb ? converge_speed_ipb[converge_speed] in brctrl_to_package()
951 0xBF21, go->ipb ? 2 : 0, in brctrl_to_package()
952 0xBF22, go->ipb ? LAMBDA_table[0][lambda / 2 + 50] in brctrl_to_package()
954 0xBF23, go->ipb ? LAMBDA_table[1][lambda] : 32767, in brctrl_to_package()
1008 0xBF46, (go->width >> 4) * (go->height >> 4), in brctrl_to_package()
1076 static int config_package(struct go7007 *go, __le16 *code, int space) in config_package() argument
1078 int fps = go->sensor_framerate / go->fps_scale / 1000; in config_package()
1079 int rows = go->interlace_coding ? go->height / 32 : go->height / 16; in config_package()
1089 0xc6c3, go->format == V4L2_PIX_FMT_MPEG4 ? 0 : in config_package()
1090 (go->format == V4L2_PIX_FMT_H263 ? 0 : 1), in config_package()
1091 0xc680, go->format == V4L2_PIX_FMT_MPEG4 ? 0xf1 : in config_package()
1092 (go->format == V4L2_PIX_FMT_H263 ? 0x61 : in config_package()
1107 0xd472, (go->board_info->sensor_flags & in config_package()
1109 (!go->interlace_coding) ? in config_package()
1111 0xd475, (go->board_info->sensor_flags & in config_package()
1113 (!go->interlace_coding) ? in config_package()
1115 0xc404, go->interlace_coding ? 0x44 : in config_package()
1116 (go->format == V4L2_PIX_FMT_MPEG4 ? 0x11 : in config_package()
1117 (go->format == V4L2_PIX_FMT_MPEG1 ? 0x02 : in config_package()
1118 (go->format == V4L2_PIX_FMT_MPEG2 ? 0x04 : in config_package()
1119 (go->format == V4L2_PIX_FMT_H263 ? 0x08 : in config_package()
1121 0xbf0a, (go->format == V4L2_PIX_FMT_MPEG4 ? 8 : in config_package()
1122 (go->format == V4L2_PIX_FMT_MPEG1 ? 1 : in config_package()
1123 (go->format == V4L2_PIX_FMT_MPEG2 ? 2 : in config_package()
1124 (go->format == V4L2_PIX_FMT_H263 ? 4 : 16)))) | in config_package()
1125 ((go->repeat_seqhead ? 1 : 0) << 6) | in config_package()
1126 ((go->dvd_mode ? 1 : 0) << 9) | in config_package()
1127 ((go->gop_header_enable ? 1 : 0) << 10), in config_package()
1129 0xdd5a, go->ipb ? 0x14 : 0x0a, in config_package()
1133 0xc40a, (go->width << 4) | rows, in config_package()
1134 0xe01a, go->board_info->hpi_buffer_cap, in config_package()
1163 0xbfe3, go->ipb ? 3 : 1, in config_package()
1164 0xc031, go->board_info->sensor_flags & in config_package()
1169 0xdd88, go->ipb ? 0x1401 : 0x0a01, in config_package()
1170 0xdd90, go->ipb ? 0x1401 : 0x0a01, in config_package()
1182 0xbfec, (go->interlace_coding ? 1 << 15 : 0) | in config_package()
1183 (go->modet_enable ? 0xa : 0) | in config_package()
1184 (go->board_info->sensor_flags & in config_package()
1189 0xbff0, go->board_info->sensor_flags & in config_package()
1198 static int seqhead_to_package(struct go7007 *go, __le16 *code, int space, in seqhead_to_package() argument
1199 int (*sequence_header_func)(struct go7007 *go, in seqhead_to_package() argument
1202 int vop_time_increment_bitlength = vti_bitlen(go); in seqhead_to_package()
1203 int fps = go->sensor_framerate / go->fps_scale * in seqhead_to_package()
1204 (go->interlace_coding ? 2 : 1); in seqhead_to_package()
1206 int len = sequence_header_func(go, buf, 1); in seqhead_to_package()
1277 static int avsync_to_package(struct go7007 *go, __le16 *code, int space) in avsync_to_package() argument
1279 int arate = go->board_info->audio_rate * 1001 * go->fps_scale; in avsync_to_package()
1280 int ratio = arate / go->sensor_framerate; in avsync_to_package()
1282 int rprime = relative_prime(go->sensor_framerate, in avsync_to_package()
1283 arate % go->sensor_framerate); in avsync_to_package()
1284 int f1 = (arate % go->sensor_framerate) / rprime; in avsync_to_package()
1285 int f2 = (go->sensor_framerate - arate % go->sensor_framerate) / rprime; in avsync_to_package()
1308 static int final_package(struct go7007 *go, __le16 *code, int space) in final_package() argument
1310 int rows = go->interlace_coding ? go->height / 32 : go->height / 16; in final_package()
1320 ((go->board_info->sensor_flags & GO7007_SENSOR_TV) && in final_package()
1321 (!go->interlace_coding) ? in final_package()
1323 ((go->encoder_subsample ? 1 : 0) << 8) | in final_package()
1324 (go->board_info->sensor_flags & in final_package()
1326 ((go->encoder_v_halve ? 1 : 0) << 14) | in final_package()
1327 (go->encoder_v_halve ? rows << 9 : rows << 8) | in final_package()
1328 (go->encoder_h_halve ? 1 << 6 : 0) | in final_package()
1329 (go->encoder_h_halve ? go->width >> 3 : go->width >> 4), in final_package()
1330 (1 << 15) | (go->encoder_v_offset << 6) | in final_package()
1331 (1 << 7) | (go->encoder_h_offset >> 2), in final_package()
1335 ((go->fps_scale - 1) << 8) | in final_package()
1336 (go->board_info->sensor_flags & GO7007_SENSOR_TV ? in final_package()
1339 go->ipb ? 0xd4c : 0x36b, in final_package()
1340 (rows << 8) | (go->width >> 4), in final_package()
1341 go->format == V4L2_PIX_FMT_MPEG4 ? 0x0404 : 0, in final_package()
1342 (1 << 15) | ((go->interlace_coding ? 1 : 0) << 13) | in final_package()
1343 ((go->closed_gop ? 1 : 0) << 12) | in final_package()
1344 ((go->format == V4L2_PIX_FMT_MPEG4 ? 1 : 0) << 11) | in final_package()
1346 ((go->ipb ? 3 : 0) << 7) | in final_package()
1347 ((go->modet_enable ? 1 : 0) << 2) | in final_package()
1348 ((go->dvd_mode ? 1 : 0) << 1) | 1, in final_package()
1349 (go->format == V4L2_PIX_FMT_MPEG1 ? 0x89a0 : in final_package()
1350 (go->format == V4L2_PIX_FMT_MPEG2 ? 0x89a0 : in final_package()
1351 (go->format == V4L2_PIX_FMT_MJPEG ? 0x89a0 : in final_package()
1352 (go->format == V4L2_PIX_FMT_MPEG4 ? 0x8920 : in final_package()
1353 (go->format == V4L2_PIX_FMT_H263 ? 0x8920 : 0))))), in final_package()
1354 go->ipb ? 0x1f15 : 0x1f0b, in final_package()
1355 go->ipb ? 0x0015 : 0x000b, in final_package()
1356 go->ipb ? 0xa800 : 0x5800, in final_package()
1364 go->ipb ? (go->gop_size / 3) : go->gop_size, in final_package()
1365 (go->height >> 4) * (go->width >> 4) * 110 / 100, in final_package()
1371 static int audio_to_package(struct go7007 *go, __le16 *code, int space) in audio_to_package() argument
1373 int clock_config = ((go->board_info->audio_flags & in audio_to_package()
1375 ((go->board_info->audio_flags & in audio_to_package()
1377 (((go->board_info->audio_bclk_div / 4) - 1) << 4) | in audio_to_package()
1378 (go->board_info->audio_main_div - 1); in audio_to_package()
1392 0x9001, (go->board_info->audio_flags & 0xffff) | in audio_to_package()
1394 0x9000, ((go->board_info->audio_flags & in audio_to_package()
1421 static int modet_to_package(struct go7007 *go, __le16 *code, int space) in modet_to_package() argument
1423 bool has_modet0 = go->modet[0].enable; in modet_to_package()
1424 bool has_modet1 = go->modet[1].enable; in modet_to_package()
1425 bool has_modet2 = go->modet[2].enable; in modet_to_package()
1426 bool has_modet3 = go->modet[3].enable; in modet_to_package()
1431 0xbf82, has_modet0 ? go->modet[0].pixel_threshold : 32767, in modet_to_package()
1432 0xbf83, has_modet1 ? go->modet[1].pixel_threshold : 32767, in modet_to_package()
1433 0xbf84, has_modet2 ? go->modet[2].pixel_threshold : 32767, in modet_to_package()
1434 0xbf85, has_modet3 ? go->modet[3].pixel_threshold : 32767, in modet_to_package()
1435 0xbf86, has_modet0 ? go->modet[0].motion_threshold : 32767, in modet_to_package()
1436 0xbf87, has_modet1 ? go->modet[1].motion_threshold : 32767, in modet_to_package()
1437 0xbf88, has_modet2 ? go->modet[2].motion_threshold : 32767, in modet_to_package()
1438 0xbf89, has_modet3 ? go->modet[3].motion_threshold : 32767, in modet_to_package()
1439 0xbf8a, has_modet0 ? go->modet[0].mb_threshold : 32767, in modet_to_package()
1440 0xbf8b, has_modet1 ? go->modet[1].mb_threshold : 32767, in modet_to_package()
1441 0xbf8c, has_modet2 ? go->modet[2].mb_threshold : 32767, in modet_to_package()
1442 0xbf8d, has_modet3 ? go->modet[3].mb_threshold : 32767, in modet_to_package()
1458 pack[i * 2 + 3] |= go->modet_map[mb]; in modet_to_package()
1494 static noinline_for_stack int do_special(struct go7007 *go, u16 type, in do_special() argument
1499 switch (go->format) { in do_special()
1501 return gen_mjpeghdr_to_package(go, code, space); in do_special()
1504 return gen_mpeg1hdr_to_package(go, code, space, in do_special()
1507 return gen_mpeg4hdr_to_package(go, code, space, in do_special()
1514 return brctrl_to_package(go, code, space, framelen); in do_special()
1516 return config_package(go, code, space); in do_special()
1518 switch (go->format) { in do_special()
1521 return seqhead_to_package(go, code, space, in do_special()
1524 return seqhead_to_package(go, code, space, in do_special()
1530 return avsync_to_package(go, code, space); in do_special()
1532 return final_package(go, code, space); in do_special()
1534 return audio_to_package(go, code, space); in do_special()
1536 return modet_to_package(go, code, space); in do_special()
1538 dev_err(go->dev, in do_special()
1543 int go7007_construct_fw_image(struct go7007 *go, u8 **fw, int *fwlen) in go7007_construct_fw_image() argument
1552 switch (go->format) { in go7007_construct_fw_image()
1568 if (request_firmware(&fw_entry, GO7007_FW_NAME, go->dev)) { in go7007_construct_fw_image()
1569 dev_err(go->dev, in go7007_construct_fw_image()
1584 dev_err(go->dev, in go7007_construct_fw_image()
1591 ret = do_special(go, __le16_to_cpu(src[2]), in go7007_construct_fw_image()
1594 dev_err(go->dev, in go7007_construct_fw_image()
1601 dev_err(go->dev, in go7007_construct_fw_image()