diff mbox series

[2/2] Input: synaptics-rmi4 - fix enum_fmt

Message ID 20180920133124.29099-2-p.zabel@pengutronix.de (mailing list archive)
State Mainlined
Commit 9a952206904de36cd11f3ca50b2fad01d789e25e
Headers show
Series [1/2] Input: synaptics-rmi4 - fill initial format | expand

Commit Message

Philipp Zabel Sept. 20, 2018, 1:31 p.m. UTC
Do not enumerate all formats, some of which the device may not even
support. Instead, only report the one fixed format of the currently
selected input that will survive try_fmt/s_fmt.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/input/rmi4/rmi_f54.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

Comments

Dmitry Torokhov April 27, 2019, 12:32 a.m. UTC | #1
On Thu, Sep 20, 2018 at 03:31:24PM +0200, Philipp Zabel wrote:
> Do not enumerate all formats, some of which the device may not even
> support. Instead, only report the one fixed format of the currently
> selected input that will survive try_fmt/s_fmt.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

Applied, thank you.

> ---
>  drivers/input/rmi4/rmi_f54.c | 20 +++++---------------
>  1 file changed, 5 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/input/rmi4/rmi_f54.c b/drivers/input/rmi4/rmi_f54.c
> index 9ccf7ee0fc67..516fea06ed59 100644
> --- a/drivers/input/rmi4/rmi_f54.c
> +++ b/drivers/input/rmi4/rmi_f54.c
> @@ -456,25 +456,15 @@ static int rmi_f54_vidioc_fmt(struct file *file, void *priv,
>  static int rmi_f54_vidioc_enum_fmt(struct file *file, void *priv,
>  				   struct v4l2_fmtdesc *fmt)
>  {
> +	struct f54_data *f54 = video_drvdata(file);
> +
>  	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
>  		return -EINVAL;
>  
> -	switch (fmt->index) {
> -	case 0:
> -		fmt->pixelformat = V4L2_TCH_FMT_DELTA_TD16;
> -		break;
> -
> -	case 1:
> -		fmt->pixelformat = V4L2_TCH_FMT_DELTA_TD08;
> -		break;
> -
> -	case 2:
> -		fmt->pixelformat = V4L2_TCH_FMT_TU16;
> -		break;
> -
> -	default:
> +	if (fmt->index)
>  		return -EINVAL;
> -	}
> +
> +	fmt->pixelformat = f54->format.pixelformat;
>  
>  	return 0;
>  }
> -- 
> 2.19.0
>
diff mbox series

Patch

diff --git a/drivers/input/rmi4/rmi_f54.c b/drivers/input/rmi4/rmi_f54.c
index 9ccf7ee0fc67..516fea06ed59 100644
--- a/drivers/input/rmi4/rmi_f54.c
+++ b/drivers/input/rmi4/rmi_f54.c
@@ -456,25 +456,15 @@  static int rmi_f54_vidioc_fmt(struct file *file, void *priv,
 static int rmi_f54_vidioc_enum_fmt(struct file *file, void *priv,
 				   struct v4l2_fmtdesc *fmt)
 {
+	struct f54_data *f54 = video_drvdata(file);
+
 	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
 		return -EINVAL;
 
-	switch (fmt->index) {
-	case 0:
-		fmt->pixelformat = V4L2_TCH_FMT_DELTA_TD16;
-		break;
-
-	case 1:
-		fmt->pixelformat = V4L2_TCH_FMT_DELTA_TD08;
-		break;
-
-	case 2:
-		fmt->pixelformat = V4L2_TCH_FMT_TU16;
-		break;
-
-	default:
+	if (fmt->index)
 		return -EINVAL;
-	}
+
+	fmt->pixelformat = f54->format.pixelformat;
 
 	return 0;
 }