94
94
#define ARDUCAM_64MP_TEST_PATTERN_B_DEFAULT 0
95
95
#define ARDUCAM_64MP_TEST_PATTERN_GB_DEFAULT 0
96
96
97
- /* Embedded metadata stream structure */
98
- #define ARDUCAM_64MP_EMBEDDED_LINE_WIDTH (11560 * 3)
99
- #define ARDUCAM_64MP_NUM_EMBEDDED_LINES 1
100
-
101
- enum pad_types {
102
- IMAGE_PAD ,
103
- METADATA_PAD ,
104
- NUM_PADS
105
- };
106
-
107
97
/* ARDUCAM_64MP native and active pixel array size. */
108
98
#define ARDUCAM_64MP_NATIVE_WIDTH 9344U
109
99
#define ARDUCAM_64MP_NATIVE_HEIGHT 7032U
@@ -1422,7 +1412,7 @@ static const char * const arducam_64mp_supply_name[] = {
1422
1412
1423
1413
struct arducam_64mp {
1424
1414
struct v4l2_subdev sd ;
1425
- struct media_pad pad [ NUM_PADS ] ;
1415
+ struct media_pad pad ;
1426
1416
1427
1417
unsigned int fmt_code ;
1428
1418
@@ -1555,9 +1545,7 @@ static int arducam_64mp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1555
1545
{
1556
1546
struct arducam_64mp * arducam_64mp = to_arducam_64mp (sd );
1557
1547
struct v4l2_mbus_framefmt * try_fmt_img =
1558
- v4l2_subdev_state_get_format (fh -> state , IMAGE_PAD );
1559
- struct v4l2_mbus_framefmt * try_fmt_meta =
1560
- v4l2_subdev_state_get_format (fh -> state , METADATA_PAD );
1548
+ v4l2_subdev_state_get_format (fh -> state , 0 );
1561
1549
struct v4l2_rect * try_crop ;
1562
1550
1563
1551
mutex_lock (& arducam_64mp -> mutex );
@@ -1568,14 +1556,8 @@ static int arducam_64mp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1568
1556
try_fmt_img -> code = arducam_64mp_get_format_code (arducam_64mp );
1569
1557
try_fmt_img -> field = V4L2_FIELD_NONE ;
1570
1558
1571
- /* Initialize try_fmt for the embedded metadata pad */
1572
- try_fmt_meta -> width = ARDUCAM_64MP_EMBEDDED_LINE_WIDTH ;
1573
- try_fmt_meta -> height = ARDUCAM_64MP_NUM_EMBEDDED_LINES ;
1574
- try_fmt_meta -> code = MEDIA_BUS_FMT_SENSOR_DATA ;
1575
- try_fmt_meta -> field = V4L2_FIELD_NONE ;
1576
-
1577
1559
/* Initialize try_crop */
1578
- try_crop = v4l2_subdev_state_get_crop (fh -> state , IMAGE_PAD );
1560
+ try_crop = v4l2_subdev_state_get_crop (fh -> state , 0 );
1579
1561
try_crop -> left = ARDUCAM_64MP_PIXEL_ARRAY_LEFT ;
1580
1562
try_crop -> top = ARDUCAM_64MP_PIXEL_ARRAY_TOP ;
1581
1563
try_crop -> width = ARDUCAM_64MP_PIXEL_ARRAY_WIDTH ;
@@ -1731,20 +1713,13 @@ static int arducam_64mp_enum_mbus_code(struct v4l2_subdev *sd,
1731
1713
{
1732
1714
struct arducam_64mp * arducam_64mp = to_arducam_64mp (sd );
1733
1715
1734
- if (code -> pad >= NUM_PADS )
1716
+ if (code -> pad >= 1 )
1735
1717
return - EINVAL ;
1736
1718
1737
- if (code -> pad == IMAGE_PAD ) {
1738
- if (code -> index > 0 )
1739
- return - EINVAL ;
1719
+ if (code -> index > 0 )
1720
+ return - EINVAL ;
1740
1721
1741
- code -> code = arducam_64mp_get_format_code (arducam_64mp );
1742
- } else {
1743
- if (code -> index > 0 )
1744
- return - EINVAL ;
1745
-
1746
- code -> code = MEDIA_BUS_FMT_SENSOR_DATA ;
1747
- }
1722
+ code -> code = arducam_64mp_get_format_code (arducam_64mp );
1748
1723
1749
1724
return 0 ;
1750
1725
}
@@ -1755,29 +1730,19 @@ static int arducam_64mp_enum_frame_size(struct v4l2_subdev *sd,
1755
1730
{
1756
1731
struct arducam_64mp * arducam_64mp = to_arducam_64mp (sd );
1757
1732
1758
- if (fse -> pad >= NUM_PADS )
1733
+ if (fse -> pad >= 1 )
1759
1734
return - EINVAL ;
1760
1735
1761
- if (fse -> pad == IMAGE_PAD ) {
1762
- if (fse -> index >= ARRAY_SIZE (supported_modes ))
1763
- return - EINVAL ;
1764
-
1765
- if (fse -> code != arducam_64mp_get_format_code (arducam_64mp ))
1766
- return - EINVAL ;
1736
+ if (fse -> index >= ARRAY_SIZE (supported_modes ))
1737
+ return - EINVAL ;
1767
1738
1768
- fse -> min_width = supported_modes [fse -> index ].width ;
1769
- fse -> max_width = fse -> min_width ;
1770
- fse -> min_height = supported_modes [fse -> index ].height ;
1771
- fse -> max_height = fse -> min_height ;
1772
- } else {
1773
- if (fse -> code != MEDIA_BUS_FMT_SENSOR_DATA || fse -> index > 0 )
1774
- return - EINVAL ;
1739
+ if (fse -> code != arducam_64mp_get_format_code (arducam_64mp ))
1740
+ return - EINVAL ;
1775
1741
1776
- fse -> min_width = ARDUCAM_64MP_EMBEDDED_LINE_WIDTH ;
1777
- fse -> max_width = fse -> min_width ;
1778
- fse -> min_height = ARDUCAM_64MP_NUM_EMBEDDED_LINES ;
1779
- fse -> max_height = fse -> min_height ;
1780
- }
1742
+ fse -> min_width = supported_modes [fse -> index ].width ;
1743
+ fse -> max_width = fse -> min_width ;
1744
+ fse -> min_height = supported_modes [fse -> index ].height ;
1745
+ fse -> max_height = fse -> min_height ;
1781
1746
1782
1747
return 0 ;
1783
1748
}
@@ -1803,22 +1768,13 @@ arducam_64mp_update_image_pad_format(struct arducam_64mp *arducam_64mp,
1803
1768
arducam_64mp_reset_colorspace (& fmt -> format );
1804
1769
}
1805
1770
1806
- static void
1807
- arducam_64mp_update_metadata_pad_format (struct v4l2_subdev_format * fmt )
1808
- {
1809
- fmt -> format .width = ARDUCAM_64MP_EMBEDDED_LINE_WIDTH ;
1810
- fmt -> format .height = ARDUCAM_64MP_NUM_EMBEDDED_LINES ;
1811
- fmt -> format .code = MEDIA_BUS_FMT_SENSOR_DATA ;
1812
- fmt -> format .field = V4L2_FIELD_NONE ;
1813
- }
1814
-
1815
1771
static int arducam_64mp_get_pad_format (struct v4l2_subdev * sd ,
1816
1772
struct v4l2_subdev_state * sd_state ,
1817
1773
struct v4l2_subdev_format * fmt )
1818
1774
{
1819
1775
struct arducam_64mp * arducam_64mp = to_arducam_64mp (sd );
1820
1776
1821
- if (fmt -> pad >= NUM_PADS )
1777
+ if (fmt -> pad >= 1 )
1822
1778
return - EINVAL ;
1823
1779
1824
1780
mutex_lock (& arducam_64mp -> mutex );
@@ -1827,20 +1783,13 @@ static int arducam_64mp_get_pad_format(struct v4l2_subdev *sd,
1827
1783
struct v4l2_mbus_framefmt * try_fmt =
1828
1784
v4l2_subdev_state_get_format (sd_state , fmt -> pad );
1829
1785
/* update the code which could change due to vflip or hflip: */
1830
- try_fmt -> code = fmt -> pad == IMAGE_PAD ?
1831
- arducam_64mp_get_format_code (arducam_64mp ) :
1832
- MEDIA_BUS_FMT_SENSOR_DATA ;
1786
+ try_fmt -> code = arducam_64mp_get_format_code (arducam_64mp );
1833
1787
fmt -> format = * try_fmt ;
1834
1788
} else {
1835
- if (fmt -> pad == IMAGE_PAD ) {
1836
- arducam_64mp_update_image_pad_format (arducam_64mp ,
1837
- arducam_64mp -> mode ,
1838
- fmt );
1839
- fmt -> format .code =
1840
- arducam_64mp_get_format_code (arducam_64mp );
1841
- } else {
1842
- arducam_64mp_update_metadata_pad_format (fmt );
1843
- }
1789
+ arducam_64mp_update_image_pad_format (arducam_64mp ,
1790
+ arducam_64mp -> mode , fmt );
1791
+ fmt -> format .code =
1792
+ arducam_64mp_get_format_code (arducam_64mp );
1844
1793
}
1845
1794
1846
1795
mutex_unlock (& arducam_64mp -> mutex );
@@ -1908,39 +1857,26 @@ static int arducam_64mp_set_pad_format(struct v4l2_subdev *sd,
1908
1857
const struct arducam_64mp_mode * mode ;
1909
1858
struct arducam_64mp * arducam_64mp = to_arducam_64mp (sd );
1910
1859
1911
- if (fmt -> pad >= NUM_PADS )
1860
+ if (fmt -> pad >= 1 )
1912
1861
return - EINVAL ;
1913
1862
1914
1863
mutex_lock (& arducam_64mp -> mutex );
1915
1864
1916
- if (fmt -> pad == IMAGE_PAD ) {
1917
- /* Bayer order varies with flips */
1918
- fmt -> format .code = arducam_64mp_get_format_code (arducam_64mp );
1919
-
1920
- mode = v4l2_find_nearest_size (supported_modes ,
1921
- ARRAY_SIZE (supported_modes ),
1922
- width , height ,
1923
- fmt -> format .width ,
1924
- fmt -> format .height );
1925
- arducam_64mp_update_image_pad_format (arducam_64mp , mode , fmt );
1926
- if (fmt -> which == V4L2_SUBDEV_FORMAT_TRY ) {
1927
- framefmt = v4l2_subdev_state_get_format (sd_state ,
1928
- fmt -> pad );
1929
- * framefmt = fmt -> format ;
1930
- } else {
1931
- arducam_64mp -> mode = mode ;
1932
- arducam_64mp -> fmt_code = fmt -> format .code ;
1933
- arducam_64mp_set_framing_limits (arducam_64mp );
1934
- }
1865
+ /* Bayer order varies with flips */
1866
+ fmt -> format .code = arducam_64mp_get_format_code (arducam_64mp );
1867
+
1868
+ mode = v4l2_find_nearest_size (supported_modes ,
1869
+ ARRAY_SIZE (supported_modes ), width ,
1870
+ height , fmt -> format .width ,
1871
+ fmt -> format .height );
1872
+ arducam_64mp_update_image_pad_format (arducam_64mp , mode , fmt );
1873
+ if (fmt -> which == V4L2_SUBDEV_FORMAT_TRY ) {
1874
+ framefmt = v4l2_subdev_state_get_format (sd_state , fmt -> pad );
1875
+ * framefmt = fmt -> format ;
1935
1876
} else {
1936
- if (fmt -> which == V4L2_SUBDEV_FORMAT_TRY ) {
1937
- framefmt = v4l2_subdev_state_get_format (sd_state ,
1938
- fmt -> pad );
1939
- * framefmt = fmt -> format ;
1940
- } else {
1941
- /* Only one embedded data mode is supported */
1942
- arducam_64mp_update_metadata_pad_format (fmt );
1943
- }
1877
+ arducam_64mp -> mode = mode ;
1878
+ arducam_64mp -> fmt_code = fmt -> format .code ;
1879
+ arducam_64mp_set_framing_limits (arducam_64mp );
1944
1880
}
1945
1881
1946
1882
mutex_unlock (& arducam_64mp -> mutex );
@@ -2545,11 +2481,10 @@ static int arducam_64mp_probe(struct i2c_client *client)
2545
2481
arducam_64mp -> sd .entity .function = MEDIA_ENT_F_CAM_SENSOR ;
2546
2482
2547
2483
/* Initialize source pads */
2548
- arducam_64mp -> pad [IMAGE_PAD ].flags = MEDIA_PAD_FL_SOURCE ;
2549
- arducam_64mp -> pad [METADATA_PAD ].flags = MEDIA_PAD_FL_SOURCE ;
2484
+ arducam_64mp -> pad .flags = MEDIA_PAD_FL_SOURCE ;
2550
2485
2551
- ret = media_entity_pads_init (& arducam_64mp -> sd .entity , NUM_PADS ,
2552
- arducam_64mp -> pad );
2486
+ ret = media_entity_pads_init (& arducam_64mp -> sd .entity , 1 ,
2487
+ & arducam_64mp -> pad );
2553
2488
if (ret ) {
2554
2489
dev_err (dev , "failed to init entity pads: %d\n" , ret );
2555
2490
goto error_handler_free ;
0 commit comments