Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: pci: mgb4: Add support for GMSL1 modules

Add support for GMSL1 modules. GMSL1 modules have 2 inputs, 2 outputs and
require a separate FW (id #3).

Signed-off-by: Martin Tůma <martin.tuma@digiteqautomotive.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Martin Tůma and committed by
Hans Verkuil
a20cf188 f422140e

+189 -71
+18 -4
drivers/media/pci/mgb4/mgb4_core.c
··· 381 381 return 0; 382 382 } 383 383 384 + static const char *module_type_str(struct mgb4_dev *mgbdev) 385 + { 386 + if (MGB4_IS_FPDL3(mgbdev)) 387 + return "FPDL3"; 388 + else if (MGB4_IS_GMSL3(mgbdev)) 389 + return "GMSL3"; 390 + else if (MGB4_IS_GMSL1(mgbdev)) 391 + return "GMSL1"; 392 + else 393 + return "UNKNOWN"; 394 + } 395 + 384 396 static int get_module_version(struct mgb4_dev *mgbdev) 385 397 { 386 398 struct device *dev = &mgbdev->pdev->dev; ··· 414 402 } 415 403 416 404 mgbdev->module_version = ~((u32)version) & 0xff; 417 - if (!(MGB4_IS_FPDL3(mgbdev) || MGB4_IS_GMSL(mgbdev))) { 405 + if (!(MGB4_IS_FPDL3(mgbdev) || 406 + MGB4_IS_GMSL3(mgbdev) || 407 + MGB4_IS_GMSL1(mgbdev))) { 418 408 dev_err(dev, "unknown module type\n"); 419 409 return -EINVAL; 420 410 } 421 411 fw_version = mgb4_read_reg(&mgbdev->video, 0xC4) >> 24; 422 412 if ((MGB4_IS_FPDL3(mgbdev) && fw_version != 1) || 423 - (MGB4_IS_GMSL(mgbdev) && fw_version != 2)) { 413 + (MGB4_IS_GMSL3(mgbdev) && fw_version != 2) || 414 + (MGB4_IS_GMSL1(mgbdev) && fw_version != 3)) { 424 415 dev_err(dev, "module/firmware type mismatch\n"); 425 416 return -EINVAL; 426 417 } 427 418 428 - dev_info(dev, "%s module detected\n", 429 - MGB4_IS_FPDL3(mgbdev) ? "FPDL3" : "GMSL"); 419 + dev_info(dev, "%s module detected\n", module_type_str(mgbdev)); 430 420 431 421 return 0; 432 422 }
+6 -3
drivers/media/pci/mgb4/mgb4_core.h
··· 18 18 #define MGB4_VIN_DEVICES 2 19 19 #define MGB4_VOUT_DEVICES 2 20 20 21 - #define MGB4_IS_GMSL(mgbdev) \ 21 + #define MGB4_IS_GMSL1(mgbdev) \ 22 + (((mgbdev)->module_version >> 4) == 6) 23 + #define MGB4_IS_GMSL3(mgbdev) \ 22 24 ((((mgbdev)->module_version >> 4) >= 2) && \ 23 25 (((mgbdev)->module_version >> 4) <= 4)) 24 26 #define MGB4_IS_FPDL3(mgbdev) \ 25 27 (((mgbdev)->module_version >> 4) == 1) 26 28 #define MGB4_HAS_VOUT(mgbdev) \ 27 - ((((mgbdev)->module_version >> 4) >= 1) && \ 28 - (((mgbdev)->module_version >> 4) <= 3)) 29 + (((((mgbdev)->module_version >> 4) >= 1) && \ 30 + (((mgbdev)->module_version >> 4) <= 3)) || \ 31 + ((((mgbdev)->module_version >> 4) == 6))) 29 32 30 33 struct mgb4_dma_channel { 31 34 struct dma_chan *chan;
+4 -2
drivers/media/pci/mgb4/mgb4_sysfs.h
··· 11 11 12 12 extern struct attribute *mgb4_pci_attrs[]; 13 13 extern struct attribute *mgb4_fpdl3_in_attrs[]; 14 - extern struct attribute *mgb4_gmsl_in_attrs[]; 14 + extern struct attribute *mgb4_gmsl3_in_attrs[]; 15 + extern struct attribute *mgb4_gmsl1_in_attrs[]; 15 16 extern struct attribute *mgb4_fpdl3_out_attrs[]; 16 - extern struct attribute *mgb4_gmsl_out_attrs[]; 17 + extern struct attribute *mgb4_gmsl3_out_attrs[]; 18 + extern struct attribute *mgb4_gmsl1_out_attrs[]; 17 19 18 20 #endif
+39 -10
drivers/media/pci/mgb4/mgb4_sysfs_in.c
··· 36 36 u32 config; 37 37 int ret; 38 38 39 - i2c_reg = MGB4_IS_GMSL(mgbdev) ? 0x1CE : 0x49; 40 - i2c_mask = MGB4_IS_GMSL(mgbdev) ? 0x0E : 0x03; 41 - i2c_single_val = MGB4_IS_GMSL(mgbdev) ? 0x00 : 0x02; 42 - i2c_dual_val = MGB4_IS_GMSL(mgbdev) ? 0x0E : 0x00; 39 + if (MGB4_IS_GMSL1(mgbdev)) 40 + return sprintf(buf, "0\n"); 41 + 42 + i2c_reg = MGB4_IS_GMSL3(mgbdev) ? 0x1CE : 0x49; 43 + i2c_mask = MGB4_IS_GMSL3(mgbdev) ? 0x0E : 0x03; 44 + i2c_single_val = MGB4_IS_GMSL3(mgbdev) ? 0x00 : 0x02; 45 + i2c_dual_val = MGB4_IS_GMSL3(mgbdev) ? 0x0E : 0x00; 43 46 44 47 mutex_lock(&mgbdev->i2c_lock); 45 48 ret = mgb4_i2c_read_byte(&vindev->deser, i2c_reg); ··· 82 79 if (ret) 83 80 return ret; 84 81 82 + if (MGB4_IS_GMSL1(mgbdev)) 83 + return val ? -EINVAL : count; 84 + 85 85 switch (val) { 86 86 case 0: /* single */ 87 87 fpga_data = 0; 88 - i2c_data = MGB4_IS_GMSL(mgbdev) ? 0x00 : 0x02; 88 + i2c_data = MGB4_IS_GMSL3(mgbdev) ? 0x00 : 0x02; 89 89 break; 90 90 case 1: /* dual */ 91 91 fpga_data = 1U << 9; 92 - i2c_data = MGB4_IS_GMSL(mgbdev) ? 0x0E : 0x00; 92 + i2c_data = MGB4_IS_GMSL3(mgbdev) ? 0x0E : 0x00; 93 93 break; 94 94 default: 95 95 return -EINVAL; 96 96 } 97 97 98 - i2c_reg = MGB4_IS_GMSL(mgbdev) ? 0x1CE : 0x49; 99 - i2c_mask = MGB4_IS_GMSL(mgbdev) ? 0x0E : 0x03; 98 + i2c_reg = MGB4_IS_GMSL3(mgbdev) ? 0x1CE : 0x49; 99 + i2c_mask = MGB4_IS_GMSL3(mgbdev) ? 0x0E : 0x03; 100 100 101 101 mutex_lock(&mgbdev->i2c_lock); 102 102 ret = mgb4_i2c_mask_byte(&vindev->deser, i2c_reg, i2c_mask, i2c_data); ··· 108 102 return -EIO; 109 103 mgb4_mask_reg(&mgbdev->video, vindev->config->regs.config, 1U << 9, 110 104 fpga_data); 111 - if (MGB4_IS_GMSL(mgbdev)) { 105 + if (MGB4_IS_GMSL3(mgbdev)) { 112 106 /* reset input link */ 113 107 mutex_lock(&mgbdev->i2c_lock); 114 108 ret = mgb4_i2c_mask_byte(&vindev->deser, 0x10, 1U << 5, 1U << 5); ··· 751 745 NULL 752 746 }; 753 747 754 - struct attribute *mgb4_gmsl_in_attrs[] = { 748 + struct attribute *mgb4_gmsl3_in_attrs[] = { 755 749 &dev_attr_input_id.attr, 756 750 &dev_attr_link_status.attr, 757 751 &dev_attr_stream_status.attr, ··· 774 768 &dev_attr_gmsl_mode.attr, 775 769 &dev_attr_gmsl_stream_id.attr, 776 770 &dev_attr_gmsl_fec.attr, 771 + NULL 772 + }; 773 + 774 + struct attribute *mgb4_gmsl1_in_attrs[] = { 775 + &dev_attr_input_id.attr, 776 + &dev_attr_link_status.attr, 777 + &dev_attr_stream_status.attr, 778 + &dev_attr_video_width.attr, 779 + &dev_attr_video_height.attr, 780 + &dev_attr_hsync_status.attr, 781 + &dev_attr_vsync_status.attr, 782 + &dev_attr_oldi_lane_width.attr, 783 + &dev_attr_color_mapping.attr, 784 + &dev_attr_hsync_gap_length.attr, 785 + &dev_attr_vsync_gap_length.attr, 786 + &dev_attr_pclk_frequency.attr, 787 + &dev_attr_hsync_width.attr, 788 + &dev_attr_vsync_width.attr, 789 + &dev_attr_hback_porch.attr, 790 + &dev_attr_hfront_porch.attr, 791 + &dev_attr_vback_porch.attr, 792 + &dev_attr_vfront_porch.attr, 793 + &dev_attr_frequency_range.attr, 777 794 NULL 778 795 };
+30 -8
drivers/media/pci/mgb4/mgb4_sysfs_out.c
··· 665 665 { 666 666 struct video_device *vdev = to_video_device(dev); 667 667 struct mgb4_vout_dev *voutdev = video_get_drvdata(vdev); 668 + struct mgb4_dev *mgbdev = voutdev->mgbdev; 668 669 unsigned long val; 669 670 int ret; 670 671 unsigned int dp; ··· 680 679 return -EBUSY; 681 680 } 682 681 683 - dp = (val > 50000) ? 1 : 0; 682 + dp = (MGB4_IS_FPDL3(mgbdev) && val > 50000) ? 1 : 0; 684 683 voutdev->freq = mgb4_cmt_set_vout_freq(voutdev, val >> dp) << dp; 685 - 686 - mgb4_mask_reg(&voutdev->mgbdev->video, voutdev->config->regs.config, 687 - 0x10, dp << 4); 688 - mutex_lock(&voutdev->mgbdev->i2c_lock); 689 - ret = mgb4_i2c_mask_byte(&voutdev->ser, 0x4F, 1 << 6, ((~dp) & 1) << 6); 690 - mutex_unlock(&voutdev->mgbdev->i2c_lock); 684 + mgb4_mask_reg(&mgbdev->video, voutdev->config->regs.config, 0x10, 685 + dp << 4); 686 + if (MGB4_IS_FPDL3(mgbdev)) { 687 + mutex_lock(&mgbdev->i2c_lock); 688 + ret = mgb4_i2c_mask_byte(&voutdev->ser, 0x4F, 1 << 6, 689 + ((~dp) & 1) << 6); 690 + mutex_unlock(&mgbdev->i2c_lock); 691 + } 691 692 692 693 mutex_unlock(voutdev->vdev.lock); 693 694 ··· 734 731 NULL 735 732 }; 736 733 737 - struct attribute *mgb4_gmsl_out_attrs[] = { 734 + struct attribute *mgb4_gmsl3_out_attrs[] = { 738 735 &dev_attr_output_id.attr, 739 736 &dev_attr_video_source.attr, 740 737 &dev_attr_display_width.attr, 741 738 &dev_attr_display_height.attr, 742 739 &dev_attr_frame_rate.attr, 740 + NULL 741 + }; 742 + 743 + struct attribute *mgb4_gmsl1_out_attrs[] = { 744 + &dev_attr_output_id.attr, 745 + &dev_attr_video_source.attr, 746 + &dev_attr_display_width.attr, 747 + &dev_attr_display_height.attr, 748 + &dev_attr_frame_rate.attr, 749 + &dev_attr_hsync_polarity.attr, 750 + &dev_attr_vsync_polarity.attr, 751 + &dev_attr_de_polarity.attr, 752 + &dev_attr_pclk_frequency.attr, 753 + &dev_attr_hsync_width.attr, 754 + &dev_attr_vsync_width.attr, 755 + &dev_attr_hback_porch.attr, 756 + &dev_attr_hfront_porch.attr, 757 + &dev_attr_vback_porch.attr, 758 + &dev_attr_vfront_porch.attr, 743 759 NULL 744 760 };
+47 -25
drivers/media/pci/mgb4/mgb4_vin.c
··· 32 32 #include "mgb4_vin.h" 33 33 34 34 ATTRIBUTE_GROUPS(mgb4_fpdl3_in); 35 - ATTRIBUTE_GROUPS(mgb4_gmsl_in); 35 + ATTRIBUTE_GROUPS(mgb4_gmsl3_in); 36 + ATTRIBUTE_GROUPS(mgb4_gmsl1_in); 36 37 37 38 static const struct mgb4_vin_config vin_cfg[] = { 38 39 {0, 0, 0, 6, {0x10, 0x00, 0x04, 0x08, 0x1C, 0x14, 0x18, 0x20, 0x24, 0x28, 0xE8}}, ··· 45 44 {I2C_BOARD_INFO("deserializer2", 0x36)}, 46 45 }; 47 46 48 - static const struct i2c_board_info gmsl_deser_info[] = { 47 + static const struct i2c_board_info gmsl3_deser_info[] = { 49 48 {I2C_BOARD_INFO("deserializer1", 0x4C)}, 50 49 {I2C_BOARD_INFO("deserializer2", 0x2A)}, 50 + }; 51 + 52 + static const struct i2c_board_info gmsl1_deser_info[] = { 53 + {I2C_BOARD_INFO("deserializer1", 0x2C)}, 54 + {I2C_BOARD_INFO("deserializer2", 0x6C)}, 51 55 }; 52 56 53 57 static const struct mgb4_i2c_kv fpdl3_i2c[] = { ··· 60 54 {0x49, 0xFF, 0x00}, {0x34, 0xFF, 0x00}, {0x23, 0xFF, 0x00} 61 55 }; 62 56 63 - static const struct mgb4_i2c_kv gmsl_i2c[] = { 57 + static const struct mgb4_i2c_kv gmsl3_i2c[] = { 64 58 {0x01, 0x03, 0x03}, {0x300, 0x0C, 0x0C}, {0x03, 0xC0, 0xC0}, 65 59 {0x1CE, 0x0E, 0x0E}, {0x11, 0x05, 0x00}, {0x05, 0xC0, 0x40}, 66 60 {0x307, 0x0F, 0x00}, {0xA0, 0x03, 0x00}, {0x3E0, 0x07, 0x07}, 67 61 {0x308, 0x01, 0x01}, {0x10, 0x20, 0x20}, {0x300, 0x40, 0x40} 62 + }; 63 + 64 + static const struct mgb4_i2c_kv gmsl1_i2c[] = { 68 65 }; 69 66 70 67 static const struct v4l2_dv_timings_cap video_timings_cap = { ··· 805 796 806 797 static int deser_init(struct mgb4_vin_dev *vindev, int id) 807 798 { 808 - int rv, addr_size; 809 - size_t values_count; 810 - const struct mgb4_i2c_kv *values; 811 - const struct i2c_board_info *info; 799 + int rv, addr_size = 0; 800 + size_t count = 0; 801 + const struct mgb4_i2c_kv *values = NULL; 802 + const struct i2c_board_info *info = NULL; 812 803 struct device *dev = &vindev->mgbdev->pdev->dev; 813 804 814 - if (MGB4_IS_GMSL(vindev->mgbdev)) { 815 - info = &gmsl_deser_info[id]; 805 + if (MGB4_IS_GMSL3(vindev->mgbdev)) { 806 + info = &gmsl3_deser_info[id]; 816 807 addr_size = 16; 817 - values = gmsl_i2c; 818 - values_count = ARRAY_SIZE(gmsl_i2c); 819 - } else { 808 + values = gmsl3_i2c; 809 + count = ARRAY_SIZE(gmsl3_i2c); 810 + } else if (MGB4_IS_FPDL3(vindev->mgbdev)) { 820 811 info = &fpdl3_deser_info[id]; 821 812 addr_size = 8; 822 813 values = fpdl3_i2c; 823 - values_count = ARRAY_SIZE(fpdl3_i2c); 814 + count = ARRAY_SIZE(fpdl3_i2c); 815 + } else if (MGB4_IS_GMSL1(vindev->mgbdev)) { 816 + info = &gmsl1_deser_info[id]; 817 + addr_size = 8; 818 + values = gmsl1_i2c; 819 + count = ARRAY_SIZE(gmsl1_i2c); 820 + } else { 821 + return -EINVAL; 824 822 } 825 823 826 824 rv = mgb4_i2c_init(&vindev->deser, vindev->mgbdev->i2c_adap, info, ··· 836 820 dev_err(dev, "failed to create deserializer\n"); 837 821 return rv; 838 822 } 839 - rv = mgb4_i2c_configure(&vindev->deser, values, values_count); 823 + rv = mgb4_i2c_configure(&vindev->deser, values, count); 840 824 if (rv < 0) { 841 825 dev_err(dev, "failed to configure deserializer\n"); 842 826 goto err_i2c_dev; ··· 854 838 { 855 839 struct mgb4_regs *video = &vindev->mgbdev->video; 856 840 const struct mgb4_vin_regs *regs = &vindev->config->regs; 841 + int dp = MGB4_IS_GMSL1(vindev->mgbdev) ? 0 : 1; 857 842 858 843 mgb4_write_reg(video, regs->config, 0x00000001); 859 844 mgb4_write_reg(video, regs->sync, 0x03E80002); 860 845 mgb4_write_reg(video, regs->padding, 0x00000000); 861 - mgb4_write_reg(video, regs->config, 1U << 9); 846 + mgb4_write_reg(video, regs->config, dp << 9); 862 847 } 863 848 864 849 static void create_debugfs(struct mgb4_vin_dev *vindev) ··· 907 890 #endif 908 891 } 909 892 893 + static const struct attribute_group **module_groups(struct mgb4_dev *mgbdev) 894 + { 895 + if (MGB4_IS_FPDL3(mgbdev)) 896 + return mgb4_fpdl3_in_groups; 897 + else if (MGB4_IS_GMSL3(mgbdev)) 898 + return mgb4_gmsl3_in_groups; 899 + else if (MGB4_IS_GMSL1(mgbdev)) 900 + return mgb4_gmsl1_in_groups; 901 + else 902 + return NULL; 903 + } 904 + 910 905 struct mgb4_vin_dev *mgb4_vin_create(struct mgb4_dev *mgbdev, int id) 911 906 { 912 907 int rv; 913 - const struct attribute_group **groups; 914 908 struct mgb4_vin_dev *vindev; 915 909 struct pci_dev *pdev = mgbdev->pdev; 916 910 struct device *dev = &pdev->dev; ··· 942 914 INIT_WORK(&vindev->dma_work, dma_transfer); 943 915 INIT_WORK(&vindev->err_work, signal_change); 944 916 945 - /* IRQ callback */ 917 + /* IRQ callbacks */ 946 918 vin_irq = xdma_get_user_irq(mgbdev->xdev, vindev->config->vin_irq); 947 919 rv = request_irq(vin_irq, vin_handler, 0, "mgb4-vin", vindev); 948 920 if (rv) { 949 921 dev_err(dev, "failed to register vin irq handler\n"); 950 922 goto err_alloc; 951 923 } 952 - /* Error IRQ callback */ 953 924 err_irq = xdma_get_user_irq(mgbdev->xdev, vindev->config->err_irq); 954 925 rv = request_irq(err_irq, err_handler, 0, "mgb4-err", vindev); 955 926 if (rv) { ··· 1013 986 } 1014 987 1015 988 /* Module sysfs attributes */ 1016 - groups = MGB4_IS_GMSL(mgbdev) 1017 - ? mgb4_gmsl_in_groups : mgb4_fpdl3_in_groups; 1018 - rv = device_add_groups(&vindev->vdev.dev, groups); 989 + rv = device_add_groups(&vindev->vdev.dev, module_groups(mgbdev)); 1019 990 if (rv) { 1020 991 dev_err(dev, "failed to create sysfs attributes\n"); 1021 992 goto err_video_dev; ··· 1039 1014 1040 1015 void mgb4_vin_free(struct mgb4_vin_dev *vindev) 1041 1016 { 1042 - const struct attribute_group **groups; 1043 1017 int vin_irq = xdma_get_user_irq(vindev->mgbdev->xdev, 1044 1018 vindev->config->vin_irq); 1045 1019 int err_irq = xdma_get_user_irq(vindev->mgbdev->xdev, ··· 1049 1025 free_irq(vin_irq, vindev); 1050 1026 free_irq(err_irq, vindev); 1051 1027 1052 - groups = MGB4_IS_GMSL(vindev->mgbdev) 1053 - ? mgb4_gmsl_in_groups : mgb4_fpdl3_in_groups; 1054 - device_remove_groups(&vindev->vdev.dev, groups); 1028 + device_remove_groups(&vindev->vdev.dev, module_groups(vindev->mgbdev)); 1055 1029 1056 1030 mgb4_i2c_free(&vindev->deser); 1057 1031 video_unregister_device(&vindev->vdev);
+45 -19
drivers/media/pci/mgb4/mgb4_vout.c
··· 25 25 #include "mgb4_vout.h" 26 26 27 27 ATTRIBUTE_GROUPS(mgb4_fpdl3_out); 28 - ATTRIBUTE_GROUPS(mgb4_gmsl_out); 28 + ATTRIBUTE_GROUPS(mgb4_gmsl3_out); 29 + ATTRIBUTE_GROUPS(mgb4_gmsl1_out); 29 30 30 31 static const struct mgb4_vout_config vout_cfg[] = { 31 32 {0, 0, 8, {0x78, 0x60, 0x64, 0x68, 0x74, 0x6C, 0x70, 0x7C, 0xE0}}, ··· 38 37 {I2C_BOARD_INFO("serializer2", 0x16)}, 39 38 }; 40 39 40 + static const struct i2c_board_info gmsl1_ser_info[] = { 41 + {I2C_BOARD_INFO("serializer1", 0x24)}, 42 + {I2C_BOARD_INFO("serializer2", 0x22)}, 43 + }; 44 + 41 45 static const struct mgb4_i2c_kv fpdl3_i2c[] = { 42 46 {0x05, 0xFF, 0x04}, {0x06, 0xFF, 0x01}, {0xC2, 0xFF, 0x80} 47 + }; 48 + 49 + static const struct mgb4_i2c_kv gmsl1_i2c[] = { 43 50 }; 44 51 45 52 static const struct v4l2_dv_timings_cap video_timings_cap = { ··· 643 634 644 635 static int ser_init(struct mgb4_vout_dev *voutdev, int id) 645 636 { 646 - int rv; 647 - const struct i2c_board_info *info = &fpdl3_ser_info[id]; 648 637 struct mgb4_i2c_client *ser = &voutdev->ser; 649 638 struct device *dev = &voutdev->mgbdev->pdev->dev; 639 + const struct i2c_board_info *info = NULL; 640 + const struct mgb4_i2c_kv *values = NULL; 641 + size_t count = 0; 642 + int rv; 650 643 651 - if (MGB4_IS_GMSL(voutdev->mgbdev)) 644 + if (MGB4_IS_FPDL3(voutdev->mgbdev)) { 645 + info = &fpdl3_ser_info[id]; 646 + values = fpdl3_i2c; 647 + count = ARRAY_SIZE(fpdl3_i2c); 648 + } else if (MGB4_IS_GMSL1(voutdev->mgbdev)) { 649 + info = &gmsl1_ser_info[id]; 650 + values = gmsl1_i2c; 651 + count = ARRAY_SIZE(gmsl1_i2c); 652 + } 653 + 654 + if (!info) 652 655 return 0; 653 656 654 657 rv = mgb4_i2c_init(ser, voutdev->mgbdev->i2c_adap, info, 8); ··· 668 647 dev_err(dev, "failed to create serializer\n"); 669 648 return rv; 670 649 } 671 - rv = mgb4_i2c_configure(ser, fpdl3_i2c, ARRAY_SIZE(fpdl3_i2c)); 650 + rv = mgb4_i2c_configure(ser, values, count); 672 651 if (rv < 0) { 673 652 dev_err(dev, "failed to configure serializer\n"); 674 653 goto err_i2c_dev; ··· 686 665 { 687 666 struct mgb4_regs *video = &voutdev->mgbdev->video; 688 667 const struct mgb4_vout_regs *regs = &voutdev->config->regs; 668 + int dp = MGB4_IS_GMSL1(voutdev->mgbdev) ? 0 : 1; 669 + u32 source = (voutdev->config->id + MGB4_VIN_DEVICES) << 2; 689 670 690 - mgb4_write_reg(video, regs->config, 0x00000011); 671 + mgb4_write_reg(video, regs->config, 0x00000001); 691 672 mgb4_write_reg(video, regs->resolution, (1280 << 16) | 640); 692 673 mgb4_write_reg(video, regs->hsync, 0x00283232); 693 674 mgb4_write_reg(video, regs->vsync, 0x40141F1E); 694 675 mgb4_write_reg(video, regs->frame_limit, MGB4_HW_FREQ / 60); 695 676 mgb4_write_reg(video, regs->padding, 0x00000000); 696 677 697 - voutdev->freq = mgb4_cmt_set_vout_freq(voutdev, 61150 >> 1) << 1; 678 + voutdev->freq = mgb4_cmt_set_vout_freq(voutdev, 61150 >> dp) << dp; 698 679 699 - mgb4_write_reg(video, regs->config, 700 - (voutdev->config->id + MGB4_VIN_DEVICES) << 2 | 1 << 4); 680 + mgb4_write_reg(video, regs->config, source | dp << 4); 701 681 } 702 682 703 683 static void create_debugfs(struct mgb4_vout_dev *voutdev) ··· 742 720 #endif 743 721 } 744 722 723 + static const struct attribute_group **module_groups(struct mgb4_dev *mgbdev) 724 + { 725 + if (MGB4_IS_FPDL3(mgbdev)) 726 + return mgb4_fpdl3_out_groups; 727 + else if (MGB4_IS_GMSL3(mgbdev)) 728 + return mgb4_gmsl3_out_groups; 729 + else if (MGB4_IS_GMSL1(mgbdev)) 730 + return mgb4_gmsl1_out_groups; 731 + else 732 + return NULL; 733 + } 734 + 745 735 struct mgb4_vout_dev *mgb4_vout_create(struct mgb4_dev *mgbdev, int id) 746 736 { 747 737 int rv, irq; 748 - const struct attribute_group **groups; 749 738 struct mgb4_vout_dev *voutdev; 750 739 struct pci_dev *pdev = mgbdev->pdev; 751 740 struct device *dev = &pdev->dev; ··· 837 804 } 838 805 839 806 /* Module sysfs attributes */ 840 - groups = MGB4_IS_GMSL(mgbdev) 841 - ? mgb4_gmsl_out_groups : mgb4_fpdl3_out_groups; 842 - rv = device_add_groups(&voutdev->vdev.dev, groups); 807 + rv = device_add_groups(&voutdev->vdev.dev, module_groups(mgbdev)); 843 808 if (rv) { 844 809 dev_err(dev, "failed to create sysfs attributes\n"); 845 810 goto err_video_dev; ··· 861 830 862 831 void mgb4_vout_free(struct mgb4_vout_dev *voutdev) 863 832 { 864 - const struct attribute_group **groups; 865 833 int irq = xdma_get_user_irq(voutdev->mgbdev->xdev, voutdev->config->irq); 866 834 867 835 free_irq(irq, voutdev); 868 - 869 - groups = MGB4_IS_GMSL(voutdev->mgbdev) 870 - ? mgb4_gmsl_out_groups : mgb4_fpdl3_out_groups; 871 - device_remove_groups(&voutdev->vdev.dev, groups); 872 - 836 + device_remove_groups(&voutdev->vdev.dev, module_groups(voutdev->mgbdev)); 873 837 mgb4_i2c_free(&voutdev->ser); 874 838 video_unregister_device(&voutdev->vdev); 875 839 v4l2_device_unregister(&voutdev->v4l2dev);