VI can output different pixel formats for the same
CSI input format. This change enables both UYVY and
NV16 formats for YUV422 input.
Thus user-space applications can see both the supported
formats and select the prefer one.
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'AR24'
Name : BGRA-8-8-8-8
Index : 1
Type : Video Capture
Pixel Format: 'NV16'
Name : NV16
Index : 2
Type : Video Capture
Pixel Format: 'UYVY'
Name : YUV 4:2:2
Bug
1779149
Change-Id: I92c190e0dbf19be770503c7e3dfa5223b9ac1dcf
Signed-off-by: Ken Chang <kenc@nvidia.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-on: http://git-master/r/
1215349
(cherry picked from commit
08e5a55057ece99b8d0c25e5a684802ec769c8ab)
Reviewed-on: http://git-master/r/
1237409
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
for (i = 0; i < ARRAY_SIZE(tegra_csi_tpg_fmts); i++) {
const struct tegra_video_format *format =
- tegra_core_get_format_by_code(tegra_csi_tpg_fmts[i].code);
+ tegra_core_get_format_by_code(
+ tegra_csi_tpg_fmts[i].code, 0);
if (format && format->fourcc == fse->code)
break;
}
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
return 0;
- vf = tegra_core_get_format_by_code(format->code);
+ vf = tegra_core_get_format_by_code(format->code, 0);
if (!vf) {
dev_err(chan->csi->dev, "Fail to find tegra video fmt");
mutex_unlock(&chan->format_lock);
/* no more formats */
break;
- pixel_format_index = tegra_core_get_idx_by_code(code.code);
- if (pixel_format_index >= 0) {
+ pixel_format_index = tegra_core_get_idx_by_code(code.code, 0);
+ while (pixel_format_index >= 0) {
bitmap_set(chan->fmts_bitmap, pixel_format_index, 1);
+ /* Set init_code to the first matched format */
if (!init_code)
init_code = code.code;
+ /* Look for other formats with the same mbus code */
+ pixel_format_index = tegra_core_get_idx_by_code(code.code,
+ pixel_format_index + 1);
}
code.index++;
}
if (!init_code) {
- pixel_format_index = tegra_core_get_idx_by_code(TEGRA_VF_DEF);
+ pixel_format_index = tegra_core_get_idx_by_code(TEGRA_VF_DEF, 0);
if (pixel_format_index >= 0) {
bitmap_set(chan->fmts_bitmap, pixel_format_index, 1);
init_code = TEGRA_VF_DEF;
if (ret)
return;
- chan->fmtinfo = tegra_core_get_format_by_code(fmt.format.code);
+ /* Initiate the channel format to the first matched format */
+ chan->fmtinfo = tegra_core_get_format_by_code(fmt.format.code, 0);
v4l2_fill_pix_format(&chan->format, &fmt.format);
chan->format.pixelformat = chan->fmtinfo->fourcc;
chan->format.bytesperline = chan->format.width *
return -ENOTTY;
v4l2_fill_pix_format(pix, &fmt.format);
- vfmt = tegra_core_get_format_by_code(fmt.format.code);
+ vfmt = tegra_core_get_format_by_code(fmt.format.code, 0);
if (vfmt != NULL) {
pix->pixelformat = vfmt->fourcc;
tegra_channel_fmt_align(chan,
spin_lock_init(&chan->capture_state_lock);
/* Init video format */
- chan->fmtinfo = tegra_core_get_format_by_code(TEGRA_VF_DEF);
+ chan->fmtinfo = tegra_core_get_format_by_code(TEGRA_VF_DEF, 0);
chan->format.pixelformat = chan->fmtinfo->fourcc;
chan->format.colorspace = V4L2_COLORSPACE_SRGB;
chan->format.field = V4L2_FIELD_NONE;
* given V4L2 media bus format @code, or -1 if no corresponding format can
* be found.
*/
-int tegra_core_get_idx_by_code(unsigned int code)
+int tegra_core_get_idx_by_code(unsigned int code, unsigned offset)
{
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(tegra_video_formats); ++i) {
+ for (i = offset; i < ARRAY_SIZE(tegra_video_formats); ++i) {
if (tegra_video_formats[i].code == code)
return i;
}
* be found.
*/
const struct tegra_video_format *
-tegra_core_get_format_by_code(unsigned int code)
+tegra_core_get_format_by_code(unsigned int code, unsigned offset)
{
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(tegra_video_formats); ++i) {
+ for (i = offset; i < ARRAY_SIZE(tegra_video_formats); ++i) {
if (tegra_video_formats[i].code == code)
return &tegra_video_formats[i];
}
u32 tegra_core_get_fourcc_by_idx(unsigned int index);
u32 tegra_core_get_word_count(unsigned int frame_width,
const struct tegra_video_format *fmt);
-int tegra_core_get_idx_by_code(unsigned int code);
+int tegra_core_get_idx_by_code(unsigned int code, unsigned offset);
const struct tegra_video_format *tegra_core_get_format_by_code(unsigned int
- code);
+ code, unsigned offset);
const struct tegra_video_format *tegra_core_get_format_by_fourcc(u32 fourcc);
u32 tegra_core_bytes_per_line(unsigned int width, unsigned int align,
const struct tegra_video_format *fmt);
bitmap_zero(vi->tpg_fmts_bitmap, MAX_FORMAT_NUM);
- index = tegra_core_get_idx_by_code(MEDIA_BUS_FMT_SRGGB10_1X10);
+ index = tegra_core_get_idx_by_code(MEDIA_BUS_FMT_SRGGB10_1X10, 0);
bitmap_set(vi->tpg_fmts_bitmap, index, 1);
- index = tegra_core_get_idx_by_code(MEDIA_BUS_FMT_RGB888_1X32_PADHI);
+ index = tegra_core_get_idx_by_code(MEDIA_BUS_FMT_RGB888_1X32_PADHI, 0);
bitmap_set(vi->tpg_fmts_bitmap, index, 1);
}