Lines Matching +full:video +full:- +full:codec
1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * This part handles card-specific data and detection
18 #include <linux/i2c-algo-bit.h>
25 #include <media/v4l2-common.h>
38 static int card[BUZ_MAX] = { [0 ... (BUZ_MAX - 1)] = -1 };
42 /* Default input and video norm at startup of the driver. */
44 static unsigned int default_input; /* default 0 = Composite, 1 = S-Video */
47 "Default input (0=Composite, 1=S-Video, 2=Internal)");
58 /* /dev/videoN, -1 for autodetect */
59 static int video_nr[BUZ_MAX] = { [0 ... (BUZ_MAX - 1)] = -1 };
61 MODULE_PARM_DESC(video_nr, "Video device number (-1=Auto)");
68 "Pass TV signal through to TV-out when idling");
72 MODULE_PARM_DESC(debug, "Debug level (0-5)");
76 MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver");
98 static u32 zr36060_read(struct videocodec *codec, u16 reg) in zr36060_read() argument
100 struct zoran *zr = (struct zoran *)codec->master_data->data; in zr36060_read()
105 return -1; in zr36060_read()
111 static void zr36060_write(struct videocodec *codec, u16 reg, u32 val) in zr36060_write() argument
113 struct zoran *zr = (struct zoran *)codec->master_data->data; in zr36060_write()
123 static u32 zr36050_read(struct videocodec *codec, u16 reg) in zr36050_read() argument
125 struct zoran *zr = (struct zoran *)codec->master_data->data; in zr36050_read()
129 return -1; in zr36050_read()
135 static void zr36050_write(struct videocodec *codec, u16 reg, u32 val) in zr36050_write() argument
137 struct zoran *zr = (struct zoran *)codec->master_data->data; in zr36050_write()
146 static u32 zr36016_read(struct videocodec *codec, u16 reg) in zr36016_read() argument
148 struct zoran *zr = (struct zoran *)codec->master_data->data; in zr36016_read()
152 return -1; in zr36016_read()
159 void zr36016_write(struct videocodec *codec, u16 reg, u32 val) in zr36016_write() argument
161 struct zoran *zr = (struct zoran *)codec->master_data->data; in zr36016_write()
178 /* Enable the video bus sync signals */ in dc10_init()
189 pci_write_config_dword(zr->pci_dev, 0xfc, 0x90680f15); in buz_init()
190 pci_write_config_dword(zr->pci_dev, 0x0c, 0x00012020); in buz_init()
191 pci_write_config_dword(zr->pci_dev, 0xe8, 0xc0200000); in buz_init()
201 // AverMedia 6-Eyes original driver by Christer Weinigel in avs6eyes_init()
247 pci_err(zr->pci_dev, "ZR36060 support is not enabled\n"); in codec_init()
248 return -EINVAL; in codec_init()
255 pci_err(zr->pci_dev, "ZR36050 support is not enabled\n"); in codec_init()
256 return -EINVAL; in codec_init()
263 pci_err(zr->pci_dev, "ZR36016 support is not enabled\n"); in codec_init()
264 return -EINVAL; in codec_init()
269 pci_err(zr->pci_dev, "unknown codec id %x\n", codecid); in codec_init()
270 return -EINVAL; in codec_init()
299 codec_name = codecid_to_modulename(zr->card.video_codec); in videocodec_init()
301 result = codec_init(zr, zr->card.video_codec); in videocodec_init()
303 pci_err(zr->pci_dev, "failed to load video codec %s: %d\n", in videocodec_init()
308 vfe_name = codecid_to_modulename(zr->card.video_vfe); in videocodec_init()
310 result = codec_init(zr, zr->card.video_vfe); in videocodec_init()
312 pci_err(zr->pci_dev, "failed to load video vfe %s: %d\n", in videocodec_init()
315 codec_exit(zr, zr->card.video_codec); in videocodec_init()
324 if (zr->card.video_codec != CODEC_TYPE_NONE) in videocodec_exit()
325 codec_exit(zr, zr->card.video_codec); in videocodec_exit()
326 if (zr->card.video_vfe != CODEC_TYPE_NONE) in videocodec_exit()
327 codec_exit(zr, zr->card.video_vfe); in videocodec_exit()
343 * FIXME: I cannot swap U and V in saa7114, so i do one pixel left shift in zoran (75 -> 74)
382 { 2, "S-Video" },
393 .gpio = { 2, 1, -1, 3, 7, 0, 4, 5 },
395 .gpcs = { -1, 0 },
412 { 7, "S-Video" },
422 .gpio = { 3, 0, 6, 1, 2, -1, 4, 5 },
424 .gpcs = { -1, 1},
441 { 7, "S-Video" },
452 .gpio = { 3, 0, 6, 1, 2, -1, 4, 5 },
454 .gpcs = { -1, 1 },
472 { 2, "S-Video" },
483 .gpio = { 2, 1, -1, 3, 7, 0, 4, 5 },
485 .gpcs = { -1, 0 },
503 { 2, "S-Video" },
514 .gpio = { 2, 1, -1, 3, 7, 0, 4, 5 },
516 .gpcs = { -1, 0 },
533 { 7, "S-Video" }
543 .gpio = { 1, -1, 3, 5, 7, -1, -1, -1 },
562 { 7, "S-Video" }
572 .gpio = { 1, -1, 3, 5, 7, -1, -1, -1 },
591 { 7, "S-Video" }
601 .gpio = { 1, -1, 3, -1, -1, -1, -1, -1 },
610 .name = "6-Eyes",
612 * AverMedia chose not to brand the 6-Eyes. Thus it can't be
629 { 8, "S-Video 1" },
630 { 9, "S-Video 2" },
631 {10, "S-Video 3" },
642 .gpio = { 1, 0, 3, -1, -1, -1, -1, -1 },// Validity unknown /Sam
676 zr->i2cbr |= 2; in zoran_i2c_setsda()
678 zr->i2cbr &= ~2; in zoran_i2c_setsda()
679 btwrite(zr->i2cbr, ZR36057_I2CBR); in zoran_i2c_setsda()
687 zr->i2cbr |= 1; in zoran_i2c_setscl()
689 zr->i2cbr &= ~1; in zoran_i2c_setscl()
690 btwrite(zr->i2cbr, ZR36057_I2CBR); in zoran_i2c_setscl()
704 zr->i2c_algo = zoran_i2c_bit_data_template; in zoran_register_i2c()
705 zr->i2c_algo.data = zr; in zoran_register_i2c()
706 strscpy(zr->i2c_adapter.name, ZR_DEVNAME(zr), in zoran_register_i2c()
707 sizeof(zr->i2c_adapter.name)); in zoran_register_i2c()
708 i2c_set_adapdata(&zr->i2c_adapter, &zr->v4l2_dev); in zoran_register_i2c()
709 zr->i2c_adapter.algo_data = &zr->i2c_algo; in zoran_register_i2c()
710 zr->i2c_adapter.dev.parent = &zr->pci_dev->dev; in zoran_register_i2c()
711 return i2c_bit_add_bus(&zr->i2c_adapter); in zoran_register_i2c()
716 i2c_del_adapter(&zr->i2c_adapter); in zoran_unregister_i2c()
725 pci_dbg(zr->pci_dev, "%s - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n", in zoran_check_jpg_settings()
726 __func__, settings->decimation, settings->hor_dcm, in zoran_check_jpg_settings()
727 settings->ver_dcm, settings->tmp_dcm); in zoran_check_jpg_settings()
728 pci_dbg(zr->pci_dev, "%s - x: %d, y: %d, w: %d, y: %d\n", __func__, in zoran_check_jpg_settings()
729 settings->img_x, settings->img_y, in zoran_check_jpg_settings()
730 settings->img_width, settings->img_height); in zoran_check_jpg_settings()
732 switch (settings->decimation) { in zoran_check_jpg_settings()
735 settings->hor_dcm = 1; in zoran_check_jpg_settings()
736 settings->ver_dcm = 1; in zoran_check_jpg_settings()
737 settings->tmp_dcm = 1; in zoran_check_jpg_settings()
738 settings->field_per_buff = 2; in zoran_check_jpg_settings()
739 settings->img_x = 0; in zoran_check_jpg_settings()
740 settings->img_y = 0; in zoran_check_jpg_settings()
741 settings->img_width = BUZ_MAX_WIDTH; in zoran_check_jpg_settings()
742 settings->img_height = BUZ_MAX_HEIGHT / 2; in zoran_check_jpg_settings()
746 settings->hor_dcm = 2; in zoran_check_jpg_settings()
747 settings->ver_dcm = 1; in zoran_check_jpg_settings()
748 settings->tmp_dcm = 2; in zoran_check_jpg_settings()
749 settings->field_per_buff = 1; in zoran_check_jpg_settings()
750 settings->img_x = (BUZ_MAX_WIDTH == 720) ? 8 : 0; in zoran_check_jpg_settings()
751 settings->img_y = 0; in zoran_check_jpg_settings()
752 settings->img_width = in zoran_check_jpg_settings()
754 settings->img_height = BUZ_MAX_HEIGHT / 2; in zoran_check_jpg_settings()
758 if (zr->card.type == DC10_NEW) { in zoran_check_jpg_settings()
759 pci_dbg(zr->pci_dev, in zoran_check_jpg_settings()
760 "%s - HDec by 4 is not supported on the DC10\n", in zoran_check_jpg_settings()
766 settings->hor_dcm = 4; in zoran_check_jpg_settings()
767 settings->ver_dcm = 2; in zoran_check_jpg_settings()
768 settings->tmp_dcm = 2; in zoran_check_jpg_settings()
769 settings->field_per_buff = 1; in zoran_check_jpg_settings()
770 settings->img_x = (BUZ_MAX_WIDTH == 720) ? 8 : 0; in zoran_check_jpg_settings()
771 settings->img_y = 0; in zoran_check_jpg_settings()
772 settings->img_width = in zoran_check_jpg_settings()
774 settings->img_height = BUZ_MAX_HEIGHT / 2; in zoran_check_jpg_settings()
780 if (settings->hor_dcm != 1 && settings->hor_dcm != 2 && in zoran_check_jpg_settings()
781 (zr->card.type == DC10_NEW || settings->hor_dcm != 4)) { in zoran_check_jpg_settings()
782 settings->hor_dcm = clamp(settings->hor_dcm, 1, 2); in zoran_check_jpg_settings()
785 if (settings->ver_dcm != 1 && settings->ver_dcm != 2) { in zoran_check_jpg_settings()
786 settings->ver_dcm = clamp(settings->ver_dcm, 1, 2); in zoran_check_jpg_settings()
789 if (settings->tmp_dcm != 1 && settings->tmp_dcm != 2) { in zoran_check_jpg_settings()
790 settings->tmp_dcm = clamp(settings->tmp_dcm, 1, 2); in zoran_check_jpg_settings()
793 if (settings->field_per_buff != 1 && in zoran_check_jpg_settings()
794 settings->field_per_buff != 2) { in zoran_check_jpg_settings()
795 settings->field_per_buff = clamp(settings->field_per_buff, 1, 2); in zoran_check_jpg_settings()
798 if (settings->img_x < 0) { in zoran_check_jpg_settings()
799 settings->img_x = 0; in zoran_check_jpg_settings()
802 if (settings->img_y < 0) { in zoran_check_jpg_settings()
803 settings->img_y = 0; in zoran_check_jpg_settings()
806 if (settings->img_width < 0 || settings->img_width > BUZ_MAX_WIDTH) { in zoran_check_jpg_settings()
807 settings->img_width = clamp(settings->img_width, 0, (int)BUZ_MAX_WIDTH); in zoran_check_jpg_settings()
810 if (settings->img_height < 0 || settings->img_height > BUZ_MAX_HEIGHT / 2) { in zoran_check_jpg_settings()
811 settings->img_height = clamp(settings->img_height, 0, BUZ_MAX_HEIGHT / 2); in zoran_check_jpg_settings()
814 if (settings->img_x + settings->img_width > BUZ_MAX_WIDTH) { in zoran_check_jpg_settings()
815 settings->img_x = BUZ_MAX_WIDTH - settings->img_width; in zoran_check_jpg_settings()
818 if (settings->img_y + settings->img_height > BUZ_MAX_HEIGHT / 2) { in zoran_check_jpg_settings()
819 settings->img_y = BUZ_MAX_HEIGHT / 2 - settings->img_height; in zoran_check_jpg_settings()
822 if (settings->img_width % (16 * settings->hor_dcm) != 0) { in zoran_check_jpg_settings()
823 settings->img_width -= settings->img_width % (16 * settings->hor_dcm); in zoran_check_jpg_settings()
824 if (settings->img_width == 0) in zoran_check_jpg_settings()
825 settings->img_width = 16 * settings->hor_dcm; in zoran_check_jpg_settings()
828 if (settings->img_height % (8 * settings->ver_dcm) != 0) { in zoran_check_jpg_settings()
829 settings->img_height -= settings->img_height % (8 * settings->ver_dcm); in zoran_check_jpg_settings()
830 if (settings->img_height == 0) in zoran_check_jpg_settings()
831 settings->img_height = 8 * settings->ver_dcm; in zoran_check_jpg_settings()
836 pci_err(zr->pci_dev, "%s - error in params for decimation = 0\n", __func__); in zoran_check_jpg_settings()
841 pci_err(zr->pci_dev, "%s - decimation = %d, must be 0, 1, 2 or 4\n", in zoran_check_jpg_settings()
842 __func__, settings->decimation); in zoran_check_jpg_settings()
847 if (settings->jpg_comp.quality > 100) in zoran_check_jpg_settings()
848 settings->jpg_comp.quality = 100; in zoran_check_jpg_settings()
849 if (settings->jpg_comp.quality < 5) in zoran_check_jpg_settings()
850 settings->jpg_comp.quality = 5; in zoran_check_jpg_settings()
851 if (settings->jpg_comp.APPn < 0) in zoran_check_jpg_settings()
852 settings->jpg_comp.APPn = 0; in zoran_check_jpg_settings()
853 if (settings->jpg_comp.APPn > 15) in zoran_check_jpg_settings()
854 settings->jpg_comp.APPn = 15; in zoran_check_jpg_settings()
855 if (settings->jpg_comp.APP_len < 0) in zoran_check_jpg_settings()
856 settings->jpg_comp.APP_len = 0; in zoran_check_jpg_settings()
857 if (settings->jpg_comp.APP_len > 60) in zoran_check_jpg_settings()
858 settings->jpg_comp.APP_len = 60; in zoran_check_jpg_settings()
859 if (settings->jpg_comp.COM_len < 0) in zoran_check_jpg_settings()
860 settings->jpg_comp.COM_len = 0; in zoran_check_jpg_settings()
861 if (settings->jpg_comp.COM_len > 60) in zoran_check_jpg_settings()
862 settings->jpg_comp.COM_len = 60; in zoran_check_jpg_settings()
864 return -EINVAL; in zoran_check_jpg_settings()
874 video_dev->v4l2_dev = &zr->v4l2_dev; in zoran_init_video_device()
875 video_dev->lock = &zr->lock; in zoran_init_video_device()
876 video_dev->device_caps = V4L2_CAP_STREAMING | dir; in zoran_init_video_device()
878 strscpy(video_dev->name, ZR_DEVNAME(zr), sizeof(video_dev->name)); in zoran_init_video_device()
879 video_dev->vfl_dir = VFL_DIR_RX; in zoran_init_video_device()
880 zoran_queue_init(zr, &zr->vq, V4L2_BUF_TYPE_VIDEO_CAPTURE); in zoran_init_video_device()
882 err = video_register_device(video_dev, VFL_TYPE_VIDEO, video_nr[zr->id]); in zoran_init_video_device()
891 video_unregister_device(zr->video_dev); in zoran_exit_video_devices()
892 kfree(zr->video_dev); in zoran_exit_video_devices()
899 zr->video_dev = video_device_alloc(); in zoran_init_video_devices()
900 if (!zr->video_dev) in zoran_init_video_devices()
901 return -ENOMEM; in zoran_init_video_devices()
903 err = zoran_init_video_device(zr, zr->video_dev, V4L2_CAP_VIDEO_CAPTURE); in zoran_init_video_devices()
905 kfree(zr->video_dev); in zoran_init_video_devices()
910 * v4l2_device_unregister() will care about removing zr->encoder/zr->decoder
917 pci_info(zr->pci_dev, "Initializing i2c bus...\n"); in zoran_i2c_init()
921 pci_err(zr->pci_dev, "%s - cannot initialize i2c bus\n", __func__); in zoran_i2c_init()
925 zr->decoder = v4l2_i2c_new_subdev(&zr->v4l2_dev, &zr->i2c_adapter, in zoran_i2c_init()
926 zr->card.i2c_decoder, 0, in zoran_i2c_init()
927 zr->card.addrs_decoder); in zoran_i2c_init()
928 if (!zr->decoder) { in zoran_i2c_init()
929 pci_err(zr->pci_dev, "Fail to get decoder %s\n", zr->card.i2c_decoder); in zoran_i2c_init()
930 err = -EINVAL; in zoran_i2c_init()
934 if (zr->card.i2c_encoder) { in zoran_i2c_init()
935 zr->encoder = v4l2_i2c_new_subdev(&zr->v4l2_dev, &zr->i2c_adapter, in zoran_i2c_init()
936 zr->card.i2c_encoder, 0, in zoran_i2c_init()
937 zr->card.addrs_encoder); in zoran_i2c_init()
938 if (!zr->encoder) { in zoran_i2c_init()
939 pci_err(zr->pci_dev, "Fail to get encoder %s\n", zr->card.i2c_encoder); in zoran_i2c_init()
940 err = -EINVAL; in zoran_i2c_init()
960 zr->v4l_settings.width = 192; in zoran_open_init_params()
961 zr->v4l_settings.height = 144; in zoran_open_init_params()
962 zr->v4l_settings.format = &zoran_formats[7]; /* YUY2 - YUV-4:2:2 packed */ in zoran_open_init_params()
963 zr->v4l_settings.bytesperline = zr->v4l_settings.width * in zoran_open_init_params()
964 ((zr->v4l_settings.format->depth + 7) / 8); in zoran_open_init_params()
967 zr->jpg_settings.decimation = 1; in zoran_open_init_params()
968 zr->jpg_settings.jpg_comp.quality = 50; /* default compression factor 8 */ in zoran_open_init_params()
969 if (zr->card.type != BUZ) in zoran_open_init_params()
970 zr->jpg_settings.odd_even = 1; in zoran_open_init_params()
972 zr->jpg_settings.odd_even = 0; in zoran_open_init_params()
973 zr->jpg_settings.jpg_comp.APPn = 0; in zoran_open_init_params()
974 zr->jpg_settings.jpg_comp.APP_len = 0; /* No APPn marker */ in zoran_open_init_params()
975 memset(zr->jpg_settings.jpg_comp.APP_data, 0, in zoran_open_init_params()
976 sizeof(zr->jpg_settings.jpg_comp.APP_data)); in zoran_open_init_params()
977 zr->jpg_settings.jpg_comp.COM_len = 0; /* No COM marker */ in zoran_open_init_params()
978 memset(zr->jpg_settings.jpg_comp.COM_data, 0, in zoran_open_init_params()
979 sizeof(zr->jpg_settings.jpg_comp.COM_data)); in zoran_open_init_params()
980 zr->jpg_settings.jpg_comp.jpeg_markers = in zoran_open_init_params()
982 i = zoran_check_jpg_settings(zr, &zr->jpg_settings, 0); in zoran_open_init_params()
984 pci_err(zr->pci_dev, "%s internal error\n", __func__); in zoran_open_init_params()
986 zr->buffer_size = zr->v4l_settings.bytesperline * zr->v4l_settings.height; in zoran_open_init_params()
995 pci_info(zr->pci_dev, "initializing card[%d]\n", zr->id); in zr36057_init()
1001 zr->norm = V4L2_STD_PAL; in zr36057_init()
1002 zr->timing = zr->card.tvn[ZR_NORM_PAL]; in zr36057_init()
1004 zr->norm = V4L2_STD_NTSC; in zr36057_init()
1005 zr->timing = zr->card.tvn[ZR_NORM_NTSC]; in zr36057_init()
1007 zr->norm = V4L2_STD_SECAM; in zr36057_init()
1008 zr->timing = zr->card.tvn[ZR_NORM_SECAM]; in zr36057_init()
1010 if (!zr->timing) { in zr36057_init()
1011 pci_warn(zr->pci_dev, in zr36057_init()
1012 "%s - default TV standard not supported by hardware. PAL will be used.\n", in zr36057_init()
1014 zr->norm = V4L2_STD_PAL; in zr36057_init()
1015 zr->timing = zr->card.tvn[ZR_NORM_PAL]; in zr36057_init()
1018 if (default_input > zr->card.inputs - 1) { in zr36057_init()
1019 pci_warn(zr->pci_dev, "default_input value %d out of range (0-%d)\n", in zr36057_init()
1020 default_input, zr->card.inputs - 1); in zr36057_init()
1023 zr->input = default_input; in zr36057_init()
1029 zr->stat_com = dma_alloc_coherent(&zr->pci_dev->dev, in zr36057_init()
1031 &zr->p_sc, GFP_KERNEL); in zr36057_init()
1032 if (!zr->stat_com) in zr36057_init()
1033 return -ENOMEM; in zr36057_init()
1036 zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to zr36057 */ in zr36057_init()
1038 zr->stat_comb = dma_alloc_coherent(&zr->pci_dev->dev, in zr36057_init()
1040 &zr->p_scb, GFP_KERNEL); in zr36057_init()
1041 if (!zr->stat_comb) { in zr36057_init()
1042 err = -ENOMEM; in zr36057_init()
1052 decoder_call(zr, video, s_stream, 0); in zr36057_init()
1053 encoder_call(zr, video, s_routing, 2, 0, 0); in zr36057_init()
1056 zr->initialized = 1; in zr36057_init()
1060 dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32) * 2, in zr36057_init()
1061 zr->stat_comb, zr->p_scb); in zr36057_init()
1063 dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), in zr36057_init()
1064 zr->stat_com, zr->p_sc); in zr36057_init()
1070 struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev); in zoran_remove()
1073 if (!zr->initialized) in zoran_remove()
1076 debugfs_remove_recursive(zr->dbgfs_dir); in zoran_remove()
1081 if (zr->codec) in zoran_remove()
1082 videocodec_detach(zr->codec); in zoran_remove()
1083 if (zr->vfe) in zoran_remove()
1084 videocodec_detach(zr->vfe); in zoran_remove()
1089 /* disable PCI bus-mastering */ in zoran_remove()
1093 pci_free_irq(zr->pci_dev, 0, zr); in zoran_remove()
1095 dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), in zoran_remove()
1096 zr->stat_com, zr->p_sc); in zoran_remove()
1097 dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32) * 2, in zoran_remove()
1098 zr->stat_comb, zr->p_scb); in zoran_remove()
1100 pci_disable_device(zr->pci_dev); in zoran_remove()
1103 v4l2_ctrl_handler_free(&zr->hdl); in zoran_remove()
1104 v4l2_device_unregister(&zr->v4l2_dev); in zoran_remove()
1117 m = devm_kmalloc(&zr->pci_dev->dev, sizeof(*m), GFP_KERNEL); in zoran_setup_videocodec()
1122 * magic and type are unused for master struct. Makes sense only at codec structs. in zoran_setup_videocodec()
1126 m->magic = 0L; in zoran_setup_videocodec()
1127 m->type = 0; in zoran_setup_videocodec()
1129 m->flags = CODEC_FLAG_ENCODER | CODEC_FLAG_DECODER; in zoran_setup_videocodec()
1130 strscpy(m->name, ZR_DEVNAME(zr), sizeof(m->name)); in zoran_setup_videocodec()
1131 m->data = zr; in zoran_setup_videocodec()
1135 m->readreg = zr36060_read; in zoran_setup_videocodec()
1136 m->writereg = zr36060_write; in zoran_setup_videocodec()
1137 m->flags |= CODEC_FLAG_JPEG | CODEC_FLAG_VFE; in zoran_setup_videocodec()
1140 m->readreg = zr36050_read; in zoran_setup_videocodec()
1141 m->writereg = zr36050_write; in zoran_setup_videocodec()
1142 m->flags |= CODEC_FLAG_JPEG; in zoran_setup_videocodec()
1145 m->readreg = zr36016_read; in zoran_setup_videocodec()
1146 m->writereg = zr36016_write; in zoran_setup_videocodec()
1147 m->flags |= CODEC_FLAG_VFE; in zoran_setup_videocodec()
1156 struct zoran *zr = to_zoran(sd->v4l2_dev); in zoran_subdev_notify()
1170 struct zoran *zr = container_of(ctrl->handler, struct zoran, hdl); in zoran_video_set_ctrl()
1172 switch (ctrl->id) { in zoran_video_set_ctrl()
1174 zr->jpg_settings.jpg_comp.quality = ctrl->val; in zoran_video_set_ctrl()
1175 return zoran_check_jpg_settings(zr, &zr->jpg_settings, 0); in zoran_video_set_ctrl()
1177 return -EINVAL; in zoran_video_set_ctrl()
1189 struct zoran *zr = seq->private; in zoran_debugfs_show()
1191 seq_printf(seq, "Running mode %x\n", zr->running); in zoran_debugfs_show()
1192 seq_printf(seq, "Codec mode %x\n", zr->codec_mode); in zoran_debugfs_show()
1193 seq_printf(seq, "Norm %llx\n", zr->norm); in zoran_debugfs_show()
1194 seq_printf(seq, "Input %d\n", zr->input); in zoran_debugfs_show()
1195 seq_printf(seq, "Buffersize %d\n", zr->buffer_size); in zoran_debugfs_show()
1197 seq_printf(seq, "V4L width %dx%d\n", zr->v4l_settings.width, zr->v4l_settings.height); in zoran_debugfs_show()
1198 seq_printf(seq, "V4L bytesperline %d\n", zr->v4l_settings.bytesperline); in zoran_debugfs_show()
1200 seq_printf(seq, "JPG decimation %u\n", zr->jpg_settings.decimation); in zoran_debugfs_show()
1201 seq_printf(seq, "JPG hor_dcm %u\n", zr->jpg_settings.hor_dcm); in zoran_debugfs_show()
1202 seq_printf(seq, "JPG ver_dcm %u\n", zr->jpg_settings.ver_dcm); in zoran_debugfs_show()
1203 seq_printf(seq, "JPG tmp_dcm %u\n", zr->jpg_settings.tmp_dcm); in zoran_debugfs_show()
1204 seq_printf(seq, "JPG odd_even %u\n", zr->jpg_settings.odd_even); in zoran_debugfs_show()
1206 zr->jpg_settings.img_x, in zoran_debugfs_show()
1207 zr->jpg_settings.img_y, in zoran_debugfs_show()
1208 zr->jpg_settings.img_width, in zoran_debugfs_show()
1209 zr->jpg_settings.img_height); in zoran_debugfs_show()
1211 seq_printf(seq, "Prepared %u\n", zr->prepared); in zoran_debugfs_show()
1212 seq_printf(seq, "Queued %u\n", zr->queued); in zoran_debugfs_show()
1237 /* some mainboards might not do PCI-PCI data transfer well */ in zoran_probe()
1239 pci_warn(pdev, "%s: chipset does not support reliable PCI-PCI DMA\n", in zoran_probe()
1242 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in zoran_probe()
1245 err = vb2_dma_contig_set_max_seg_size(&pdev->dev, U32_MAX); in zoran_probe()
1252 return -ENOENT; in zoran_probe()
1255 zr = devm_kzalloc(&pdev->dev, sizeof(*zr), GFP_KERNEL); in zoran_probe()
1257 return -ENOMEM; in zoran_probe()
1259 zr->v4l2_dev.notify = zoran_subdev_notify; in zoran_probe()
1260 if (v4l2_device_register(&pdev->dev, &zr->v4l2_dev)) in zoran_probe()
1262 zr->pci_dev = pdev; in zoran_probe()
1263 zr->id = nr; in zoran_probe()
1264 snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id); in zoran_probe()
1265 if (v4l2_ctrl_handler_init(&zr->hdl, 10)) in zoran_probe()
1267 zr->v4l2_dev.ctrl_handler = &zr->hdl; in zoran_probe()
1268 v4l2_ctrl_new_std(&zr->hdl, &zoran_video_ctrl_ops, in zoran_probe()
1271 spin_lock_init(&zr->spinlock); in zoran_probe()
1272 mutex_init(&zr->lock); in zoran_probe()
1275 zr->revision = zr->pci_dev->revision; in zoran_probe()
1277 pci_info(zr->pci_dev, "Zoran ZR360%c7 (rev %d), irq: %d, memory: 0x%08llx\n", in zoran_probe()
1278 zr->revision < 2 ? '5' : '6', zr->revision, in zoran_probe()
1279 zr->pci_dev->irq, (uint64_t)pci_resource_start(zr->pci_dev, 0)); in zoran_probe()
1280 if (zr->revision >= 2) in zoran_probe()
1281 pci_info(zr->pci_dev, "Subsystem vendor=0x%04x id=0x%04x\n", in zoran_probe()
1282 zr->pci_dev->subsystem_vendor, zr->pci_dev->subsystem_device); in zoran_probe()
1284 /* Use auto-detected card type? */ in zoran_probe()
1285 if (card[nr] == -1) { in zoran_probe()
1286 if (zr->revision < 2) { in zoran_probe()
1288 pci_err(pdev, "It is not possible to auto-detect ZR36057 based cards\n"); in zoran_probe()
1292 card_num = ent->driver_data; in zoran_probe()
1297 pci_info(zr->pci_dev, "%s() - card %s detected\n", __func__, in zoran_probe()
1303 card_num, NUM_CARDS - 1); in zoran_probe()
1311 * on a per-individual card basis at runtime, this is in zoran_probe()
1315 zr->card = zoran_cards[card_num]; in zoran_probe()
1317 zr->card.name, zr->id); in zoran_probe()
1323 zr->zr36057_mem = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0), in zoran_probe()
1325 if (!zr->zr36057_mem) { in zoran_probe()
1326 pci_err(pdev, "%s() - ioremap failed\n", __func__); in zoran_probe()
1332 if (result == -EINVAL) { in zoran_probe()
1333 pci_err(pdev, "%s - bad IRQ number or handler\n", __func__); in zoran_probe()
1334 } else if (result == -EBUSY) { in zoran_probe()
1335 pci_err(pdev, "%s - IRQ %d busy, change your PnP config in BIOS\n", in zoran_probe()
1336 __func__, zr->pci_dev->irq); in zoran_probe()
1338 pci_err(pdev, "%s - cannot assign IRQ, error code %d\n", __func__, result); in zoran_probe()
1344 pci_read_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, in zoran_probe()
1346 need_latency = zr->revision > 1 ? 32 : 48; in zoran_probe()
1348 pci_info(zr->pci_dev, "Changing PCI latency from %d to %d\n", in zoran_probe()
1350 pci_write_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, need_latency); in zoran_probe()
1359 pci_info(zr->pci_dev, "Initializing videocodec bus...\n"); in zoran_probe()
1364 /* reset JPEG codec */ in zoran_probe()
1367 /* video bus enabled */ in zoran_probe()
1368 /* display codec revision */ in zoran_probe()
1369 if (zr->card.video_codec != 0) { in zoran_probe()
1370 master_codec = zoran_setup_videocodec(zr, zr->card.video_codec); in zoran_probe()
1373 zr->codec = videocodec_attach(master_codec); in zoran_probe()
1374 if (!zr->codec) { in zoran_probe()
1375 pci_err(pdev, "%s - no codec found\n", __func__); in zoran_probe()
1378 if (zr->codec->type != zr->card.video_codec) { in zoran_probe()
1379 pci_err(pdev, "%s - wrong codec\n", __func__); in zoran_probe()
1383 if (zr->card.video_vfe != 0) { in zoran_probe()
1384 master_vfe = zoran_setup_videocodec(zr, zr->card.video_vfe); in zoran_probe()
1387 zr->vfe = videocodec_attach(master_vfe); in zoran_probe()
1388 if (!zr->vfe) { in zoran_probe()
1389 pci_err(pdev, "%s - no VFE found\n", __func__); in zoran_probe()
1392 if (zr->vfe->type != zr->card.video_vfe) { in zoran_probe()
1399 if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) in zoran_probe()
1400 pci_info(zr->pci_dev, "ZR36057/Natoma bug, max. buffer size is 128K\n"); in zoran_probe()
1405 zr->map_mode = ZORAN_MAP_MODE_RAW; in zoran_probe()
1407 zr->dbgfs_dir = debugfs_create_dir(ZR_DEVNAME(zr), NULL); in zoran_probe()
1408 debugfs_create_file("debug", 0444, zr->dbgfs_dir, zr, in zoran_probe()
1413 videocodec_detach(zr->vfe); in zoran_probe()
1415 videocodec_detach(zr->codec); in zoran_probe()
1422 pci_free_irq(zr->pci_dev, 0, zr); in zoran_probe()
1426 v4l2_ctrl_handler_free(&zr->hdl); in zoran_probe()
1427 v4l2_device_unregister(&zr->v4l2_dev); in zoran_probe()
1430 return -ENODEV; in zoran_probe()