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)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Sat, 7 Oct 2023 08:55:45 +0000 (10:55 +0200)
commit0aeccc63f3bc4cfd49dc4893da1409402ee6b295
tree8f9eaefe740e5adbc27446e3dca22f5e98d94992
parentc3cad51c66bbed05e126b796592ff91033bd9e4e
media: mtk-jpegenc: Fix bug in JPEG encode quality selection

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>
drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c