aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/function
diff options
context:
space:
mode:
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>2015-01-19 07:52:58 -0500
committerFelipe Balbi <balbi@ti.com>2015-01-27 11:00:27 -0500
commit578d0b6b6171e7a7afa49e74f87c683297e9cae9 (patch)
treea9e3cadb28568118e0a592ff73232bd1898d54f0 /drivers/usb/gadget/function
parent727968357eb84497ac8e2514cf06be3d8779d24f (diff)
usb: gadget: uvc: comments for iterating over streaming hierarchy
The purpose of the functions and their parametrs might not be obvious to the reader, so explain it. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/function')
-rw-r--r--drivers/usb/gadget/function/uvc_configfs.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c
index 51d8e9ee5323..3c0467bcb14f 100644
--- a/drivers/usb/gadget/function/uvc_configfs.c
+++ b/drivers/usb/gadget/function/uvc_configfs.c
@@ -1918,6 +1918,25 @@ enum uvcg_strm_type {
1918 UVCG_FRAME 1918 UVCG_FRAME
1919}; 1919};
1920 1920
1921/*
1922 * Iterate over a hierarchy of streaming descriptors' config items.
1923 * The items are created by the user with configfs.
1924 *
1925 * It "processes" the header pointed to by @priv1, then for each format
1926 * that follows the header "processes" the format itself and then for
1927 * each frame inside a format "processes" the frame.
1928 *
1929 * As a "processing" function the @fun is used.
1930 *
1931 * __uvcg_iter_strm_cls() is used in two context: first, to calculate
1932 * the amount of memory needed for an array of streaming descriptors
1933 * and second, to actually fill the array.
1934 *
1935 * @h: streaming header pointer
1936 * @priv2: an "inout" parameter (the caller might want to see the changes to it)
1937 * @priv3: an "inout" parameter (the caller might want to see the changes to it)
1938 * @fun: callback function for processing each level of the hierarchy
1939 */
1921static int __uvcg_iter_strm_cls(struct uvcg_streaming_header *h, 1940static int __uvcg_iter_strm_cls(struct uvcg_streaming_header *h,
1922 void *priv2, void *priv3, 1941 void *priv2, void *priv3,
1923 int (*fun)(void *, void *, void *, int, enum uvcg_strm_type type)) 1942 int (*fun)(void *, void *, void *, int, enum uvcg_strm_type type))
@@ -1951,6 +1970,14 @@ static int __uvcg_iter_strm_cls(struct uvcg_streaming_header *h,
1951 return ret; 1970 return ret;
1952} 1971}
1953 1972
1973/*
1974 * Count how many bytes are needed for an array of streaming descriptors.
1975 *
1976 * @priv1: pointer to a header, format or frame
1977 * @priv2: inout parameter, accumulated size of the array
1978 * @priv3: inout parameter, accumulated number of the array elements
1979 * @n: unused, this function's prototype must match @fun in __uvcg_iter_strm_cls
1980 */
1954static int __uvcg_cnt_strm(void *priv1, void *priv2, void *priv3, int n, 1981static int __uvcg_cnt_strm(void *priv1, void *priv2, void *priv3, int n,
1955 enum uvcg_strm_type type) 1982 enum uvcg_strm_type type)
1956{ 1983{
@@ -2000,6 +2027,13 @@ static int __uvcg_cnt_strm(void *priv1, void *priv2, void *priv3, int n,
2000 return 0; 2027 return 0;
2001} 2028}
2002 2029
2030/*
2031 * Fill an array of streaming descriptors.
2032 *
2033 * @priv1: pointer to a header, format or frame
2034 * @priv2: inout parameter, pointer into a block of memory
2035 * @priv3: inout parameter, pointer to a 2-dimensional array
2036 */
2003static int __uvcg_fill_strm(void *priv1, void *priv2, void *priv3, int n, 2037static int __uvcg_fill_strm(void *priv1, void *priv2, void *priv3, int n,
2004 enum uvcg_strm_type type) 2038 enum uvcg_strm_type type)
2005{ 2039{