media: mtk-jpegenc: Fix bug in JPEG encode quality selection
authorFei Shao <fshao@chromium.org>
Fri, 8 Sep 2023 13:28:04 +0000 (21:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:52:14 +0000 (11:52 +0100)
commit1620531a3dac229175306dcf9dfd6a8bba51d32c
treeafd4825ea203a645a6b733e0e05edc437b3dce79
parentb75fb8a2ee1e7f1ae49a6d2b15d27bad1eca3c4f
media: mtk-jpegenc: Fix bug in JPEG encode quality selection

[ Upstream commit 0aeccc63f3bc4cfd49dc4893da1409402ee6b295 ]

The driver uses the upper-bound approach to decide the target JPEG
encode quality, but there's a logic bug that if the desired quality is
higher than what the driver can support, the driver falls back to using
the worst quality.

Fix the bug by assuming using the best quality in the beginning, and
with trivial refactor to avoid long lines.

Fixes: 45f13a57d813 ("media: platform: Add jpeg enc feature")
Signed-off-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c