18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * vivid-vid-common.c - common video support functions. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/errno.h> 98c2ecf20Sopenharmony_ci#include <linux/kernel.h> 108c2ecf20Sopenharmony_ci#include <linux/sched.h> 118c2ecf20Sopenharmony_ci#include <linux/videodev2.h> 128c2ecf20Sopenharmony_ci#include <linux/v4l2-dv-timings.h> 138c2ecf20Sopenharmony_ci#include <media/v4l2-common.h> 148c2ecf20Sopenharmony_ci#include <media/v4l2-event.h> 158c2ecf20Sopenharmony_ci#include <media/v4l2-dv-timings.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include "vivid-core.h" 188c2ecf20Sopenharmony_ci#include "vivid-vid-common.h" 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ciconst struct v4l2_dv_timings_cap vivid_dv_timings_cap = { 218c2ecf20Sopenharmony_ci .type = V4L2_DV_BT_656_1120, 228c2ecf20Sopenharmony_ci /* keep this initialization for compatibility with GCC < 4.4.6 */ 238c2ecf20Sopenharmony_ci .reserved = { 0 }, 248c2ecf20Sopenharmony_ci V4L2_INIT_BT_TIMINGS(16, MAX_WIDTH, 16, MAX_HEIGHT, 14000000, 775000000, 258c2ecf20Sopenharmony_ci V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT | 268c2ecf20Sopenharmony_ci V4L2_DV_BT_STD_CVT | V4L2_DV_BT_STD_GTF, 278c2ecf20Sopenharmony_ci V4L2_DV_BT_CAP_PROGRESSIVE | V4L2_DV_BT_CAP_INTERLACED) 288c2ecf20Sopenharmony_ci}; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* ------------------------------------------------------------------ 318c2ecf20Sopenharmony_ci Basic structures 328c2ecf20Sopenharmony_ci ------------------------------------------------------------------*/ 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistruct vivid_fmt vivid_formats[] = { 358c2ecf20Sopenharmony_ci { 368c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YUYV, 378c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 388c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 398c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 408c2ecf20Sopenharmony_ci .planes = 1, 418c2ecf20Sopenharmony_ci .buffers = 1, 428c2ecf20Sopenharmony_ci .data_offset = { PLANE0_DATA_OFFSET }, 438c2ecf20Sopenharmony_ci }, 448c2ecf20Sopenharmony_ci { 458c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_UYVY, 468c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 478c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 488c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 498c2ecf20Sopenharmony_ci .planes = 1, 508c2ecf20Sopenharmony_ci .buffers = 1, 518c2ecf20Sopenharmony_ci }, 528c2ecf20Sopenharmony_ci { 538c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YVYU, 548c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 558c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 568c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 578c2ecf20Sopenharmony_ci .planes = 1, 588c2ecf20Sopenharmony_ci .buffers = 1, 598c2ecf20Sopenharmony_ci }, 608c2ecf20Sopenharmony_ci { 618c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_VYUY, 628c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 638c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 648c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 658c2ecf20Sopenharmony_ci .planes = 1, 668c2ecf20Sopenharmony_ci .buffers = 1, 678c2ecf20Sopenharmony_ci }, 688c2ecf20Sopenharmony_ci { 698c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YUV422P, 708c2ecf20Sopenharmony_ci .vdownsampling = { 1, 1, 1 }, 718c2ecf20Sopenharmony_ci .bit_depth = { 8, 4, 4 }, 728c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 738c2ecf20Sopenharmony_ci .planes = 3, 748c2ecf20Sopenharmony_ci .buffers = 1, 758c2ecf20Sopenharmony_ci }, 768c2ecf20Sopenharmony_ci { 778c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YUV420, 788c2ecf20Sopenharmony_ci .vdownsampling = { 1, 2, 2 }, 798c2ecf20Sopenharmony_ci .bit_depth = { 8, 4, 4 }, 808c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 818c2ecf20Sopenharmony_ci .planes = 3, 828c2ecf20Sopenharmony_ci .buffers = 1, 838c2ecf20Sopenharmony_ci }, 848c2ecf20Sopenharmony_ci { 858c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YVU420, 868c2ecf20Sopenharmony_ci .vdownsampling = { 1, 2, 2 }, 878c2ecf20Sopenharmony_ci .bit_depth = { 8, 4, 4 }, 888c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 898c2ecf20Sopenharmony_ci .planes = 3, 908c2ecf20Sopenharmony_ci .buffers = 1, 918c2ecf20Sopenharmony_ci }, 928c2ecf20Sopenharmony_ci { 938c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_NV12, 948c2ecf20Sopenharmony_ci .vdownsampling = { 1, 2 }, 958c2ecf20Sopenharmony_ci .bit_depth = { 8, 8 }, 968c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 978c2ecf20Sopenharmony_ci .planes = 2, 988c2ecf20Sopenharmony_ci .buffers = 1, 998c2ecf20Sopenharmony_ci }, 1008c2ecf20Sopenharmony_ci { 1018c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_NV21, 1028c2ecf20Sopenharmony_ci .vdownsampling = { 1, 2 }, 1038c2ecf20Sopenharmony_ci .bit_depth = { 8, 8 }, 1048c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 1058c2ecf20Sopenharmony_ci .planes = 2, 1068c2ecf20Sopenharmony_ci .buffers = 1, 1078c2ecf20Sopenharmony_ci }, 1088c2ecf20Sopenharmony_ci { 1098c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_NV16, 1108c2ecf20Sopenharmony_ci .vdownsampling = { 1, 1 }, 1118c2ecf20Sopenharmony_ci .bit_depth = { 8, 8 }, 1128c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 1138c2ecf20Sopenharmony_ci .planes = 2, 1148c2ecf20Sopenharmony_ci .buffers = 1, 1158c2ecf20Sopenharmony_ci }, 1168c2ecf20Sopenharmony_ci { 1178c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_NV61, 1188c2ecf20Sopenharmony_ci .vdownsampling = { 1, 1 }, 1198c2ecf20Sopenharmony_ci .bit_depth = { 8, 8 }, 1208c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 1218c2ecf20Sopenharmony_ci .planes = 2, 1228c2ecf20Sopenharmony_ci .buffers = 1, 1238c2ecf20Sopenharmony_ci }, 1248c2ecf20Sopenharmony_ci { 1258c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_NV24, 1268c2ecf20Sopenharmony_ci .vdownsampling = { 1, 1 }, 1278c2ecf20Sopenharmony_ci .bit_depth = { 8, 16 }, 1288c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 1298c2ecf20Sopenharmony_ci .planes = 2, 1308c2ecf20Sopenharmony_ci .buffers = 1, 1318c2ecf20Sopenharmony_ci }, 1328c2ecf20Sopenharmony_ci { 1338c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_NV42, 1348c2ecf20Sopenharmony_ci .vdownsampling = { 1, 1 }, 1358c2ecf20Sopenharmony_ci .bit_depth = { 8, 16 }, 1368c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 1378c2ecf20Sopenharmony_ci .planes = 2, 1388c2ecf20Sopenharmony_ci .buffers = 1, 1398c2ecf20Sopenharmony_ci }, 1408c2ecf20Sopenharmony_ci { 1418c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YUV555, /* uuuvvvvv ayyyyyuu */ 1428c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 1438c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 1448c2ecf20Sopenharmony_ci .planes = 1, 1458c2ecf20Sopenharmony_ci .buffers = 1, 1468c2ecf20Sopenharmony_ci .alpha_mask = 0x8000, 1478c2ecf20Sopenharmony_ci }, 1488c2ecf20Sopenharmony_ci { 1498c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YUV565, /* uuuvvvvv yyyyyuuu */ 1508c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 1518c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 1528c2ecf20Sopenharmony_ci .planes = 1, 1538c2ecf20Sopenharmony_ci .buffers = 1, 1548c2ecf20Sopenharmony_ci }, 1558c2ecf20Sopenharmony_ci { 1568c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YUV444, /* uuuuvvvv aaaayyyy */ 1578c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 1588c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 1598c2ecf20Sopenharmony_ci .planes = 1, 1608c2ecf20Sopenharmony_ci .buffers = 1, 1618c2ecf20Sopenharmony_ci .alpha_mask = 0xf000, 1628c2ecf20Sopenharmony_ci }, 1638c2ecf20Sopenharmony_ci { 1648c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YUV32, /* ayuv */ 1658c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 1668c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 1678c2ecf20Sopenharmony_ci .planes = 1, 1688c2ecf20Sopenharmony_ci .buffers = 1, 1698c2ecf20Sopenharmony_ci .alpha_mask = 0x000000ff, 1708c2ecf20Sopenharmony_ci }, 1718c2ecf20Sopenharmony_ci { 1728c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_AYUV32, 1738c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 1748c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 1758c2ecf20Sopenharmony_ci .planes = 1, 1768c2ecf20Sopenharmony_ci .buffers = 1, 1778c2ecf20Sopenharmony_ci .alpha_mask = 0x000000ff, 1788c2ecf20Sopenharmony_ci }, 1798c2ecf20Sopenharmony_ci { 1808c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_XYUV32, 1818c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 1828c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 1838c2ecf20Sopenharmony_ci .planes = 1, 1848c2ecf20Sopenharmony_ci .buffers = 1, 1858c2ecf20Sopenharmony_ci }, 1868c2ecf20Sopenharmony_ci { 1878c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_VUYA32, 1888c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 1898c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 1908c2ecf20Sopenharmony_ci .planes = 1, 1918c2ecf20Sopenharmony_ci .buffers = 1, 1928c2ecf20Sopenharmony_ci .alpha_mask = 0xff000000, 1938c2ecf20Sopenharmony_ci }, 1948c2ecf20Sopenharmony_ci { 1958c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_VUYX32, 1968c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 1978c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 1988c2ecf20Sopenharmony_ci .planes = 1, 1998c2ecf20Sopenharmony_ci .buffers = 1, 2008c2ecf20Sopenharmony_ci }, 2018c2ecf20Sopenharmony_ci { 2028c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_GREY, 2038c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2048c2ecf20Sopenharmony_ci .bit_depth = { 8 }, 2058c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_LUMA, 2068c2ecf20Sopenharmony_ci .planes = 1, 2078c2ecf20Sopenharmony_ci .buffers = 1, 2088c2ecf20Sopenharmony_ci }, 2098c2ecf20Sopenharmony_ci { 2108c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_Y10, 2118c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2128c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 2138c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_LUMA, 2148c2ecf20Sopenharmony_ci .planes = 1, 2158c2ecf20Sopenharmony_ci .buffers = 1, 2168c2ecf20Sopenharmony_ci }, 2178c2ecf20Sopenharmony_ci { 2188c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_Y12, 2198c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2208c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 2218c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_LUMA, 2228c2ecf20Sopenharmony_ci .planes = 1, 2238c2ecf20Sopenharmony_ci .buffers = 1, 2248c2ecf20Sopenharmony_ci }, 2258c2ecf20Sopenharmony_ci { 2268c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_Y16, 2278c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2288c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 2298c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_LUMA, 2308c2ecf20Sopenharmony_ci .planes = 1, 2318c2ecf20Sopenharmony_ci .buffers = 1, 2328c2ecf20Sopenharmony_ci }, 2338c2ecf20Sopenharmony_ci { 2348c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_Y16_BE, 2358c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2368c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 2378c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_LUMA, 2388c2ecf20Sopenharmony_ci .planes = 1, 2398c2ecf20Sopenharmony_ci .buffers = 1, 2408c2ecf20Sopenharmony_ci }, 2418c2ecf20Sopenharmony_ci { 2428c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGB332, /* rrrgggbb */ 2438c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2448c2ecf20Sopenharmony_ci .bit_depth = { 8 }, 2458c2ecf20Sopenharmony_ci .planes = 1, 2468c2ecf20Sopenharmony_ci .buffers = 1, 2478c2ecf20Sopenharmony_ci }, 2488c2ecf20Sopenharmony_ci { 2498c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */ 2508c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2518c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 2528c2ecf20Sopenharmony_ci .planes = 1, 2538c2ecf20Sopenharmony_ci .buffers = 1, 2548c2ecf20Sopenharmony_ci .can_do_overlay = true, 2558c2ecf20Sopenharmony_ci }, 2568c2ecf20Sopenharmony_ci { 2578c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGB565X, /* rrrrrggg gggbbbbb */ 2588c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2598c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 2608c2ecf20Sopenharmony_ci .planes = 1, 2618c2ecf20Sopenharmony_ci .buffers = 1, 2628c2ecf20Sopenharmony_ci .can_do_overlay = true, 2638c2ecf20Sopenharmony_ci }, 2648c2ecf20Sopenharmony_ci { 2658c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGB444, /* ggggbbbb xxxxrrrr */ 2668c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2678c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 2688c2ecf20Sopenharmony_ci .planes = 1, 2698c2ecf20Sopenharmony_ci .buffers = 1, 2708c2ecf20Sopenharmony_ci }, 2718c2ecf20Sopenharmony_ci { 2728c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_XRGB444, /* ggggbbbb xxxxrrrr */ 2738c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2748c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 2758c2ecf20Sopenharmony_ci .planes = 1, 2768c2ecf20Sopenharmony_ci .buffers = 1, 2778c2ecf20Sopenharmony_ci }, 2788c2ecf20Sopenharmony_ci { 2798c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_ARGB444, /* ggggbbbb aaaarrrr */ 2808c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2818c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 2828c2ecf20Sopenharmony_ci .planes = 1, 2838c2ecf20Sopenharmony_ci .buffers = 1, 2848c2ecf20Sopenharmony_ci .alpha_mask = 0x00f0, 2858c2ecf20Sopenharmony_ci }, 2868c2ecf20Sopenharmony_ci { 2878c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGBX444, /* bbbbxxxx rrrrgggg */ 2888c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2898c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 2908c2ecf20Sopenharmony_ci .planes = 1, 2918c2ecf20Sopenharmony_ci .buffers = 1, 2928c2ecf20Sopenharmony_ci }, 2938c2ecf20Sopenharmony_ci { 2948c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGBA444, /* bbbbaaaa rrrrgggg */ 2958c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 2968c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 2978c2ecf20Sopenharmony_ci .planes = 1, 2988c2ecf20Sopenharmony_ci .buffers = 1, 2998c2ecf20Sopenharmony_ci .alpha_mask = 0x00f0, 3008c2ecf20Sopenharmony_ci }, 3018c2ecf20Sopenharmony_ci { 3028c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_XBGR444, /* ggggrrrr xxxxbbbb */ 3038c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 3048c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 3058c2ecf20Sopenharmony_ci .planes = 1, 3068c2ecf20Sopenharmony_ci .buffers = 1, 3078c2ecf20Sopenharmony_ci }, 3088c2ecf20Sopenharmony_ci { 3098c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_ABGR444, /* ggggrrrr aaaabbbb */ 3108c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 3118c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 3128c2ecf20Sopenharmony_ci .planes = 1, 3138c2ecf20Sopenharmony_ci .buffers = 1, 3148c2ecf20Sopenharmony_ci .alpha_mask = 0x00f0, 3158c2ecf20Sopenharmony_ci }, 3168c2ecf20Sopenharmony_ci { 3178c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_BGRX444, /* rrrrxxxx bbbbgggg */ 3188c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 3198c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 3208c2ecf20Sopenharmony_ci .planes = 1, 3218c2ecf20Sopenharmony_ci .buffers = 1, 3228c2ecf20Sopenharmony_ci }, 3238c2ecf20Sopenharmony_ci { 3248c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_BGRA444, /* rrrraaaa bbbbgggg */ 3258c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 3268c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 3278c2ecf20Sopenharmony_ci .planes = 1, 3288c2ecf20Sopenharmony_ci .buffers = 1, 3298c2ecf20Sopenharmony_ci .alpha_mask = 0x00f0, 3308c2ecf20Sopenharmony_ci }, 3318c2ecf20Sopenharmony_ci { 3328c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGB555, /* gggbbbbb xrrrrrgg */ 3338c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 3348c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 3358c2ecf20Sopenharmony_ci .planes = 1, 3368c2ecf20Sopenharmony_ci .buffers = 1, 3378c2ecf20Sopenharmony_ci .can_do_overlay = true, 3388c2ecf20Sopenharmony_ci }, 3398c2ecf20Sopenharmony_ci { 3408c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_XRGB555, /* gggbbbbb xrrrrrgg */ 3418c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 3428c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 3438c2ecf20Sopenharmony_ci .planes = 1, 3448c2ecf20Sopenharmony_ci .buffers = 1, 3458c2ecf20Sopenharmony_ci .can_do_overlay = true, 3468c2ecf20Sopenharmony_ci }, 3478c2ecf20Sopenharmony_ci { 3488c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_ARGB555, /* gggbbbbb arrrrrgg */ 3498c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 3508c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 3518c2ecf20Sopenharmony_ci .planes = 1, 3528c2ecf20Sopenharmony_ci .buffers = 1, 3538c2ecf20Sopenharmony_ci .can_do_overlay = true, 3548c2ecf20Sopenharmony_ci .alpha_mask = 0x8000, 3558c2ecf20Sopenharmony_ci }, 3568c2ecf20Sopenharmony_ci { 3578c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGBX555, /* ggbbbbbx rrrrrggg */ 3588c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 3598c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 3608c2ecf20Sopenharmony_ci .planes = 1, 3618c2ecf20Sopenharmony_ci .buffers = 1, 3628c2ecf20Sopenharmony_ci .can_do_overlay = true, 3638c2ecf20Sopenharmony_ci }, 3648c2ecf20Sopenharmony_ci { 3658c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGBA555, /* ggbbbbba rrrrrggg */ 3668c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 3678c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 3688c2ecf20Sopenharmony_ci .planes = 1, 3698c2ecf20Sopenharmony_ci .buffers = 1, 3708c2ecf20Sopenharmony_ci .can_do_overlay = true, 3718c2ecf20Sopenharmony_ci .alpha_mask = 0x8000, 3728c2ecf20Sopenharmony_ci }, 3738c2ecf20Sopenharmony_ci { 3748c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_XBGR555, /* gggrrrrr xbbbbbgg */ 3758c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 3768c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 3778c2ecf20Sopenharmony_ci .planes = 1, 3788c2ecf20Sopenharmony_ci .buffers = 1, 3798c2ecf20Sopenharmony_ci .can_do_overlay = true, 3808c2ecf20Sopenharmony_ci }, 3818c2ecf20Sopenharmony_ci { 3828c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_ABGR555, /* gggrrrrr abbbbbgg */ 3838c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 3848c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 3858c2ecf20Sopenharmony_ci .planes = 1, 3868c2ecf20Sopenharmony_ci .buffers = 1, 3878c2ecf20Sopenharmony_ci .can_do_overlay = true, 3888c2ecf20Sopenharmony_ci .alpha_mask = 0x8000, 3898c2ecf20Sopenharmony_ci }, 3908c2ecf20Sopenharmony_ci { 3918c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_BGRX555, /* ggrrrrrx bbbbbggg */ 3928c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 3938c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 3948c2ecf20Sopenharmony_ci .planes = 1, 3958c2ecf20Sopenharmony_ci .buffers = 1, 3968c2ecf20Sopenharmony_ci .can_do_overlay = true, 3978c2ecf20Sopenharmony_ci }, 3988c2ecf20Sopenharmony_ci { 3998c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_BGRA555, /* ggrrrrra bbbbbggg */ 4008c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4018c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 4028c2ecf20Sopenharmony_ci .planes = 1, 4038c2ecf20Sopenharmony_ci .buffers = 1, 4048c2ecf20Sopenharmony_ci .can_do_overlay = true, 4058c2ecf20Sopenharmony_ci .alpha_mask = 0x8000, 4068c2ecf20Sopenharmony_ci }, 4078c2ecf20Sopenharmony_ci { 4088c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGB555X, /* xrrrrrgg gggbbbbb */ 4098c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4108c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 4118c2ecf20Sopenharmony_ci .planes = 1, 4128c2ecf20Sopenharmony_ci .buffers = 1, 4138c2ecf20Sopenharmony_ci }, 4148c2ecf20Sopenharmony_ci { 4158c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_XRGB555X, /* xrrrrrgg gggbbbbb */ 4168c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4178c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 4188c2ecf20Sopenharmony_ci .planes = 1, 4198c2ecf20Sopenharmony_ci .buffers = 1, 4208c2ecf20Sopenharmony_ci }, 4218c2ecf20Sopenharmony_ci { 4228c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_ARGB555X, /* arrrrrgg gggbbbbb */ 4238c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4248c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 4258c2ecf20Sopenharmony_ci .planes = 1, 4268c2ecf20Sopenharmony_ci .buffers = 1, 4278c2ecf20Sopenharmony_ci .alpha_mask = 0x0080, 4288c2ecf20Sopenharmony_ci }, 4298c2ecf20Sopenharmony_ci { 4308c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGB24, /* rgb */ 4318c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4328c2ecf20Sopenharmony_ci .bit_depth = { 24 }, 4338c2ecf20Sopenharmony_ci .planes = 1, 4348c2ecf20Sopenharmony_ci .buffers = 1, 4358c2ecf20Sopenharmony_ci }, 4368c2ecf20Sopenharmony_ci { 4378c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_BGR24, /* bgr */ 4388c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4398c2ecf20Sopenharmony_ci .bit_depth = { 24 }, 4408c2ecf20Sopenharmony_ci .planes = 1, 4418c2ecf20Sopenharmony_ci .buffers = 1, 4428c2ecf20Sopenharmony_ci }, 4438c2ecf20Sopenharmony_ci { 4448c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_BGR666, /* bbbbbbgg ggggrrrr rrxxxxxx */ 4458c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4468c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 4478c2ecf20Sopenharmony_ci .planes = 1, 4488c2ecf20Sopenharmony_ci .buffers = 1, 4498c2ecf20Sopenharmony_ci }, 4508c2ecf20Sopenharmony_ci { 4518c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGB32, /* xrgb */ 4528c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4538c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 4548c2ecf20Sopenharmony_ci .planes = 1, 4558c2ecf20Sopenharmony_ci .buffers = 1, 4568c2ecf20Sopenharmony_ci }, 4578c2ecf20Sopenharmony_ci { 4588c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_BGR32, /* bgrx */ 4598c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4608c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 4618c2ecf20Sopenharmony_ci .planes = 1, 4628c2ecf20Sopenharmony_ci .buffers = 1, 4638c2ecf20Sopenharmony_ci }, 4648c2ecf20Sopenharmony_ci { 4658c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_XRGB32, /* xrgb */ 4668c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4678c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 4688c2ecf20Sopenharmony_ci .planes = 1, 4698c2ecf20Sopenharmony_ci .buffers = 1, 4708c2ecf20Sopenharmony_ci }, 4718c2ecf20Sopenharmony_ci { 4728c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_XBGR32, /* bgrx */ 4738c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4748c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 4758c2ecf20Sopenharmony_ci .planes = 1, 4768c2ecf20Sopenharmony_ci .buffers = 1, 4778c2ecf20Sopenharmony_ci }, 4788c2ecf20Sopenharmony_ci { 4798c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_ARGB32, /* argb */ 4808c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4818c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 4828c2ecf20Sopenharmony_ci .planes = 1, 4838c2ecf20Sopenharmony_ci .buffers = 1, 4848c2ecf20Sopenharmony_ci .alpha_mask = 0x000000ff, 4858c2ecf20Sopenharmony_ci }, 4868c2ecf20Sopenharmony_ci { 4878c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_ABGR32, /* bgra */ 4888c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4898c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 4908c2ecf20Sopenharmony_ci .planes = 1, 4918c2ecf20Sopenharmony_ci .buffers = 1, 4928c2ecf20Sopenharmony_ci .alpha_mask = 0xff000000, 4938c2ecf20Sopenharmony_ci }, 4948c2ecf20Sopenharmony_ci { 4958c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGBX32, /* rgbx */ 4968c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 4978c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 4988c2ecf20Sopenharmony_ci .planes = 1, 4998c2ecf20Sopenharmony_ci .buffers = 1, 5008c2ecf20Sopenharmony_ci }, 5018c2ecf20Sopenharmony_ci { 5028c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_BGRX32, /* xbgr */ 5038c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5048c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 5058c2ecf20Sopenharmony_ci .planes = 1, 5068c2ecf20Sopenharmony_ci .buffers = 1, 5078c2ecf20Sopenharmony_ci }, 5088c2ecf20Sopenharmony_ci { 5098c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_RGBA32, /* rgba */ 5108c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5118c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 5128c2ecf20Sopenharmony_ci .planes = 1, 5138c2ecf20Sopenharmony_ci .buffers = 1, 5148c2ecf20Sopenharmony_ci .alpha_mask = 0x000000ff, 5158c2ecf20Sopenharmony_ci }, 5168c2ecf20Sopenharmony_ci { 5178c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_BGRA32, /* abgr */ 5188c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5198c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 5208c2ecf20Sopenharmony_ci .planes = 1, 5218c2ecf20Sopenharmony_ci .buffers = 1, 5228c2ecf20Sopenharmony_ci .alpha_mask = 0xff000000, 5238c2ecf20Sopenharmony_ci }, 5248c2ecf20Sopenharmony_ci { 5258c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SBGGR8, /* Bayer BG/GR */ 5268c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5278c2ecf20Sopenharmony_ci .bit_depth = { 8 }, 5288c2ecf20Sopenharmony_ci .planes = 1, 5298c2ecf20Sopenharmony_ci .buffers = 1, 5308c2ecf20Sopenharmony_ci }, 5318c2ecf20Sopenharmony_ci { 5328c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SGBRG8, /* Bayer GB/RG */ 5338c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5348c2ecf20Sopenharmony_ci .bit_depth = { 8 }, 5358c2ecf20Sopenharmony_ci .planes = 1, 5368c2ecf20Sopenharmony_ci .buffers = 1, 5378c2ecf20Sopenharmony_ci }, 5388c2ecf20Sopenharmony_ci { 5398c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SGRBG8, /* Bayer GR/BG */ 5408c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5418c2ecf20Sopenharmony_ci .bit_depth = { 8 }, 5428c2ecf20Sopenharmony_ci .planes = 1, 5438c2ecf20Sopenharmony_ci .buffers = 1, 5448c2ecf20Sopenharmony_ci }, 5458c2ecf20Sopenharmony_ci { 5468c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SRGGB8, /* Bayer RG/GB */ 5478c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5488c2ecf20Sopenharmony_ci .bit_depth = { 8 }, 5498c2ecf20Sopenharmony_ci .planes = 1, 5508c2ecf20Sopenharmony_ci .buffers = 1, 5518c2ecf20Sopenharmony_ci }, 5528c2ecf20Sopenharmony_ci { 5538c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SBGGR10, /* Bayer BG/GR */ 5548c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5558c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 5568c2ecf20Sopenharmony_ci .planes = 1, 5578c2ecf20Sopenharmony_ci .buffers = 1, 5588c2ecf20Sopenharmony_ci }, 5598c2ecf20Sopenharmony_ci { 5608c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SGBRG10, /* Bayer GB/RG */ 5618c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5628c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 5638c2ecf20Sopenharmony_ci .planes = 1, 5648c2ecf20Sopenharmony_ci .buffers = 1, 5658c2ecf20Sopenharmony_ci }, 5668c2ecf20Sopenharmony_ci { 5678c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SGRBG10, /* Bayer GR/BG */ 5688c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5698c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 5708c2ecf20Sopenharmony_ci .planes = 1, 5718c2ecf20Sopenharmony_ci .buffers = 1, 5728c2ecf20Sopenharmony_ci }, 5738c2ecf20Sopenharmony_ci { 5748c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SRGGB10, /* Bayer RG/GB */ 5758c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5768c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 5778c2ecf20Sopenharmony_ci .planes = 1, 5788c2ecf20Sopenharmony_ci .buffers = 1, 5798c2ecf20Sopenharmony_ci }, 5808c2ecf20Sopenharmony_ci { 5818c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SBGGR12, /* Bayer BG/GR */ 5828c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5838c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 5848c2ecf20Sopenharmony_ci .planes = 1, 5858c2ecf20Sopenharmony_ci .buffers = 1, 5868c2ecf20Sopenharmony_ci }, 5878c2ecf20Sopenharmony_ci { 5888c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SGBRG12, /* Bayer GB/RG */ 5898c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5908c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 5918c2ecf20Sopenharmony_ci .planes = 1, 5928c2ecf20Sopenharmony_ci .buffers = 1, 5938c2ecf20Sopenharmony_ci }, 5948c2ecf20Sopenharmony_ci { 5958c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SGRBG12, /* Bayer GR/BG */ 5968c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 5978c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 5988c2ecf20Sopenharmony_ci .planes = 1, 5998c2ecf20Sopenharmony_ci .buffers = 1, 6008c2ecf20Sopenharmony_ci }, 6018c2ecf20Sopenharmony_ci { 6028c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SRGGB12, /* Bayer RG/GB */ 6038c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 6048c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 6058c2ecf20Sopenharmony_ci .planes = 1, 6068c2ecf20Sopenharmony_ci .buffers = 1, 6078c2ecf20Sopenharmony_ci }, 6088c2ecf20Sopenharmony_ci { 6098c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SBGGR16, /* Bayer BG/GR */ 6108c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 6118c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 6128c2ecf20Sopenharmony_ci .planes = 1, 6138c2ecf20Sopenharmony_ci .buffers = 1, 6148c2ecf20Sopenharmony_ci }, 6158c2ecf20Sopenharmony_ci { 6168c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SGBRG16, /* Bayer GB/RG */ 6178c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 6188c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 6198c2ecf20Sopenharmony_ci .planes = 1, 6208c2ecf20Sopenharmony_ci .buffers = 1, 6218c2ecf20Sopenharmony_ci }, 6228c2ecf20Sopenharmony_ci { 6238c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SGRBG16, /* Bayer GR/BG */ 6248c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 6258c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 6268c2ecf20Sopenharmony_ci .planes = 1, 6278c2ecf20Sopenharmony_ci .buffers = 1, 6288c2ecf20Sopenharmony_ci }, 6298c2ecf20Sopenharmony_ci { 6308c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_SRGGB16, /* Bayer RG/GB */ 6318c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 6328c2ecf20Sopenharmony_ci .bit_depth = { 16 }, 6338c2ecf20Sopenharmony_ci .planes = 1, 6348c2ecf20Sopenharmony_ci .buffers = 1, 6358c2ecf20Sopenharmony_ci }, 6368c2ecf20Sopenharmony_ci { 6378c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_HSV24, /* HSV 24bits */ 6388c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_HSV, 6398c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 6408c2ecf20Sopenharmony_ci .bit_depth = { 24 }, 6418c2ecf20Sopenharmony_ci .planes = 1, 6428c2ecf20Sopenharmony_ci .buffers = 1, 6438c2ecf20Sopenharmony_ci }, 6448c2ecf20Sopenharmony_ci { 6458c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_HSV32, /* HSV 32bits */ 6468c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_HSV, 6478c2ecf20Sopenharmony_ci .vdownsampling = { 1 }, 6488c2ecf20Sopenharmony_ci .bit_depth = { 32 }, 6498c2ecf20Sopenharmony_ci .planes = 1, 6508c2ecf20Sopenharmony_ci .buffers = 1, 6518c2ecf20Sopenharmony_ci }, 6528c2ecf20Sopenharmony_ci 6538c2ecf20Sopenharmony_ci /* Multiplanar formats */ 6548c2ecf20Sopenharmony_ci 6558c2ecf20Sopenharmony_ci { 6568c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_NV16M, 6578c2ecf20Sopenharmony_ci .vdownsampling = { 1, 1 }, 6588c2ecf20Sopenharmony_ci .bit_depth = { 8, 8 }, 6598c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 6608c2ecf20Sopenharmony_ci .planes = 2, 6618c2ecf20Sopenharmony_ci .buffers = 2, 6628c2ecf20Sopenharmony_ci .data_offset = { PLANE0_DATA_OFFSET, 0 }, 6638c2ecf20Sopenharmony_ci }, 6648c2ecf20Sopenharmony_ci { 6658c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_NV61M, 6668c2ecf20Sopenharmony_ci .vdownsampling = { 1, 1 }, 6678c2ecf20Sopenharmony_ci .bit_depth = { 8, 8 }, 6688c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 6698c2ecf20Sopenharmony_ci .planes = 2, 6708c2ecf20Sopenharmony_ci .buffers = 2, 6718c2ecf20Sopenharmony_ci .data_offset = { 0, PLANE0_DATA_OFFSET }, 6728c2ecf20Sopenharmony_ci }, 6738c2ecf20Sopenharmony_ci { 6748c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YUV420M, 6758c2ecf20Sopenharmony_ci .vdownsampling = { 1, 2, 2 }, 6768c2ecf20Sopenharmony_ci .bit_depth = { 8, 4, 4 }, 6778c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 6788c2ecf20Sopenharmony_ci .planes = 3, 6798c2ecf20Sopenharmony_ci .buffers = 3, 6808c2ecf20Sopenharmony_ci }, 6818c2ecf20Sopenharmony_ci { 6828c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YVU420M, 6838c2ecf20Sopenharmony_ci .vdownsampling = { 1, 2, 2 }, 6848c2ecf20Sopenharmony_ci .bit_depth = { 8, 4, 4 }, 6858c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 6868c2ecf20Sopenharmony_ci .planes = 3, 6878c2ecf20Sopenharmony_ci .buffers = 3, 6888c2ecf20Sopenharmony_ci }, 6898c2ecf20Sopenharmony_ci { 6908c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_NV12M, 6918c2ecf20Sopenharmony_ci .vdownsampling = { 1, 2 }, 6928c2ecf20Sopenharmony_ci .bit_depth = { 8, 8 }, 6938c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 6948c2ecf20Sopenharmony_ci .planes = 2, 6958c2ecf20Sopenharmony_ci .buffers = 2, 6968c2ecf20Sopenharmony_ci }, 6978c2ecf20Sopenharmony_ci { 6988c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_NV21M, 6998c2ecf20Sopenharmony_ci .vdownsampling = { 1, 2 }, 7008c2ecf20Sopenharmony_ci .bit_depth = { 8, 8 }, 7018c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 7028c2ecf20Sopenharmony_ci .planes = 2, 7038c2ecf20Sopenharmony_ci .buffers = 2, 7048c2ecf20Sopenharmony_ci }, 7058c2ecf20Sopenharmony_ci { 7068c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YUV422M, 7078c2ecf20Sopenharmony_ci .vdownsampling = { 1, 1, 1 }, 7088c2ecf20Sopenharmony_ci .bit_depth = { 8, 4, 4 }, 7098c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 7108c2ecf20Sopenharmony_ci .planes = 3, 7118c2ecf20Sopenharmony_ci .buffers = 3, 7128c2ecf20Sopenharmony_ci }, 7138c2ecf20Sopenharmony_ci { 7148c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YVU422M, 7158c2ecf20Sopenharmony_ci .vdownsampling = { 1, 1, 1 }, 7168c2ecf20Sopenharmony_ci .bit_depth = { 8, 4, 4 }, 7178c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 7188c2ecf20Sopenharmony_ci .planes = 3, 7198c2ecf20Sopenharmony_ci .buffers = 3, 7208c2ecf20Sopenharmony_ci }, 7218c2ecf20Sopenharmony_ci { 7228c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YUV444M, 7238c2ecf20Sopenharmony_ci .vdownsampling = { 1, 1, 1 }, 7248c2ecf20Sopenharmony_ci .bit_depth = { 8, 8, 8 }, 7258c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 7268c2ecf20Sopenharmony_ci .planes = 3, 7278c2ecf20Sopenharmony_ci .buffers = 3, 7288c2ecf20Sopenharmony_ci }, 7298c2ecf20Sopenharmony_ci { 7308c2ecf20Sopenharmony_ci .fourcc = V4L2_PIX_FMT_YVU444M, 7318c2ecf20Sopenharmony_ci .vdownsampling = { 1, 1, 1 }, 7328c2ecf20Sopenharmony_ci .bit_depth = { 8, 8, 8 }, 7338c2ecf20Sopenharmony_ci .color_enc = TGP_COLOR_ENC_YCBCR, 7348c2ecf20Sopenharmony_ci .planes = 3, 7358c2ecf20Sopenharmony_ci .buffers = 3, 7368c2ecf20Sopenharmony_ci }, 7378c2ecf20Sopenharmony_ci}; 7388c2ecf20Sopenharmony_ci 7398c2ecf20Sopenharmony_ci/* There are this many multiplanar formats in the list */ 7408c2ecf20Sopenharmony_ci#define VIVID_MPLANAR_FORMATS 10 7418c2ecf20Sopenharmony_ci 7428c2ecf20Sopenharmony_ciconst struct vivid_fmt *vivid_get_format(struct vivid_dev *dev, u32 pixelformat) 7438c2ecf20Sopenharmony_ci{ 7448c2ecf20Sopenharmony_ci const struct vivid_fmt *fmt; 7458c2ecf20Sopenharmony_ci unsigned k; 7468c2ecf20Sopenharmony_ci 7478c2ecf20Sopenharmony_ci for (k = 0; k < ARRAY_SIZE(vivid_formats); k++) { 7488c2ecf20Sopenharmony_ci fmt = &vivid_formats[k]; 7498c2ecf20Sopenharmony_ci if (fmt->fourcc == pixelformat) 7508c2ecf20Sopenharmony_ci if (fmt->buffers == 1 || dev->multiplanar) 7518c2ecf20Sopenharmony_ci return fmt; 7528c2ecf20Sopenharmony_ci } 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_ci return NULL; 7558c2ecf20Sopenharmony_ci} 7568c2ecf20Sopenharmony_ci 7578c2ecf20Sopenharmony_cibool vivid_vid_can_loop(struct vivid_dev *dev) 7588c2ecf20Sopenharmony_ci{ 7598c2ecf20Sopenharmony_ci if (dev->src_rect.width != dev->sink_rect.width || 7608c2ecf20Sopenharmony_ci dev->src_rect.height != dev->sink_rect.height) 7618c2ecf20Sopenharmony_ci return false; 7628c2ecf20Sopenharmony_ci if (dev->fmt_cap->fourcc != dev->fmt_out->fourcc) 7638c2ecf20Sopenharmony_ci return false; 7648c2ecf20Sopenharmony_ci if (dev->field_cap != dev->field_out) 7658c2ecf20Sopenharmony_ci return false; 7668c2ecf20Sopenharmony_ci /* 7678c2ecf20Sopenharmony_ci * While this can be supported, it is just too much work 7688c2ecf20Sopenharmony_ci * to actually implement. 7698c2ecf20Sopenharmony_ci */ 7708c2ecf20Sopenharmony_ci if (dev->field_cap == V4L2_FIELD_SEQ_TB || 7718c2ecf20Sopenharmony_ci dev->field_cap == V4L2_FIELD_SEQ_BT) 7728c2ecf20Sopenharmony_ci return false; 7738c2ecf20Sopenharmony_ci if (vivid_is_svid_cap(dev) && vivid_is_svid_out(dev)) { 7748c2ecf20Sopenharmony_ci if (!(dev->std_cap[dev->input] & V4L2_STD_525_60) != 7758c2ecf20Sopenharmony_ci !(dev->std_out & V4L2_STD_525_60)) 7768c2ecf20Sopenharmony_ci return false; 7778c2ecf20Sopenharmony_ci return true; 7788c2ecf20Sopenharmony_ci } 7798c2ecf20Sopenharmony_ci if (vivid_is_hdmi_cap(dev) && vivid_is_hdmi_out(dev)) 7808c2ecf20Sopenharmony_ci return true; 7818c2ecf20Sopenharmony_ci return false; 7828c2ecf20Sopenharmony_ci} 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_civoid vivid_send_source_change(struct vivid_dev *dev, unsigned type) 7858c2ecf20Sopenharmony_ci{ 7868c2ecf20Sopenharmony_ci struct v4l2_event ev = { 7878c2ecf20Sopenharmony_ci .type = V4L2_EVENT_SOURCE_CHANGE, 7888c2ecf20Sopenharmony_ci .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION, 7898c2ecf20Sopenharmony_ci }; 7908c2ecf20Sopenharmony_ci unsigned i; 7918c2ecf20Sopenharmony_ci 7928c2ecf20Sopenharmony_ci for (i = 0; i < dev->num_inputs; i++) { 7938c2ecf20Sopenharmony_ci ev.id = i; 7948c2ecf20Sopenharmony_ci if (dev->input_type[i] == type) { 7958c2ecf20Sopenharmony_ci if (video_is_registered(&dev->vid_cap_dev) && dev->has_vid_cap) 7968c2ecf20Sopenharmony_ci v4l2_event_queue(&dev->vid_cap_dev, &ev); 7978c2ecf20Sopenharmony_ci if (video_is_registered(&dev->vbi_cap_dev) && dev->has_vbi_cap) 7988c2ecf20Sopenharmony_ci v4l2_event_queue(&dev->vbi_cap_dev, &ev); 7998c2ecf20Sopenharmony_ci } 8008c2ecf20Sopenharmony_ci } 8018c2ecf20Sopenharmony_ci} 8028c2ecf20Sopenharmony_ci 8038c2ecf20Sopenharmony_ci/* 8048c2ecf20Sopenharmony_ci * Conversion function that converts a single-planar format to a 8058c2ecf20Sopenharmony_ci * single-plane multiplanar format. 8068c2ecf20Sopenharmony_ci */ 8078c2ecf20Sopenharmony_civoid fmt_sp2mp(const struct v4l2_format *sp_fmt, struct v4l2_format *mp_fmt) 8088c2ecf20Sopenharmony_ci{ 8098c2ecf20Sopenharmony_ci struct v4l2_pix_format_mplane *mp = &mp_fmt->fmt.pix_mp; 8108c2ecf20Sopenharmony_ci struct v4l2_plane_pix_format *ppix = &mp->plane_fmt[0]; 8118c2ecf20Sopenharmony_ci const struct v4l2_pix_format *pix = &sp_fmt->fmt.pix; 8128c2ecf20Sopenharmony_ci bool is_out = sp_fmt->type == V4L2_BUF_TYPE_VIDEO_OUTPUT; 8138c2ecf20Sopenharmony_ci 8148c2ecf20Sopenharmony_ci memset(mp->reserved, 0, sizeof(mp->reserved)); 8158c2ecf20Sopenharmony_ci mp_fmt->type = is_out ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : 8168c2ecf20Sopenharmony_ci V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 8178c2ecf20Sopenharmony_ci mp->width = pix->width; 8188c2ecf20Sopenharmony_ci mp->height = pix->height; 8198c2ecf20Sopenharmony_ci mp->pixelformat = pix->pixelformat; 8208c2ecf20Sopenharmony_ci mp->field = pix->field; 8218c2ecf20Sopenharmony_ci mp->colorspace = pix->colorspace; 8228c2ecf20Sopenharmony_ci mp->xfer_func = pix->xfer_func; 8238c2ecf20Sopenharmony_ci /* Also copies hsv_enc */ 8248c2ecf20Sopenharmony_ci mp->ycbcr_enc = pix->ycbcr_enc; 8258c2ecf20Sopenharmony_ci mp->quantization = pix->quantization; 8268c2ecf20Sopenharmony_ci mp->num_planes = 1; 8278c2ecf20Sopenharmony_ci mp->flags = pix->flags; 8288c2ecf20Sopenharmony_ci ppix->sizeimage = pix->sizeimage; 8298c2ecf20Sopenharmony_ci ppix->bytesperline = pix->bytesperline; 8308c2ecf20Sopenharmony_ci memset(ppix->reserved, 0, sizeof(ppix->reserved)); 8318c2ecf20Sopenharmony_ci} 8328c2ecf20Sopenharmony_ci 8338c2ecf20Sopenharmony_ciint fmt_sp2mp_func(struct file *file, void *priv, 8348c2ecf20Sopenharmony_ci struct v4l2_format *f, fmtfunc func) 8358c2ecf20Sopenharmony_ci{ 8368c2ecf20Sopenharmony_ci struct v4l2_format fmt; 8378c2ecf20Sopenharmony_ci struct v4l2_pix_format_mplane *mp = &fmt.fmt.pix_mp; 8388c2ecf20Sopenharmony_ci struct v4l2_plane_pix_format *ppix = &mp->plane_fmt[0]; 8398c2ecf20Sopenharmony_ci struct v4l2_pix_format *pix = &f->fmt.pix; 8408c2ecf20Sopenharmony_ci int ret; 8418c2ecf20Sopenharmony_ci 8428c2ecf20Sopenharmony_ci /* Converts to a mplane format */ 8438c2ecf20Sopenharmony_ci fmt_sp2mp(f, &fmt); 8448c2ecf20Sopenharmony_ci /* Passes it to the generic mplane format function */ 8458c2ecf20Sopenharmony_ci ret = func(file, priv, &fmt); 8468c2ecf20Sopenharmony_ci /* Copies back the mplane data to the single plane format */ 8478c2ecf20Sopenharmony_ci pix->width = mp->width; 8488c2ecf20Sopenharmony_ci pix->height = mp->height; 8498c2ecf20Sopenharmony_ci pix->pixelformat = mp->pixelformat; 8508c2ecf20Sopenharmony_ci pix->field = mp->field; 8518c2ecf20Sopenharmony_ci pix->colorspace = mp->colorspace; 8528c2ecf20Sopenharmony_ci pix->xfer_func = mp->xfer_func; 8538c2ecf20Sopenharmony_ci /* Also copies hsv_enc */ 8548c2ecf20Sopenharmony_ci pix->ycbcr_enc = mp->ycbcr_enc; 8558c2ecf20Sopenharmony_ci pix->quantization = mp->quantization; 8568c2ecf20Sopenharmony_ci pix->sizeimage = ppix->sizeimage; 8578c2ecf20Sopenharmony_ci pix->bytesperline = ppix->bytesperline; 8588c2ecf20Sopenharmony_ci pix->flags = mp->flags; 8598c2ecf20Sopenharmony_ci return ret; 8608c2ecf20Sopenharmony_ci} 8618c2ecf20Sopenharmony_ci 8628c2ecf20Sopenharmony_ciint vivid_vid_adjust_sel(unsigned flags, struct v4l2_rect *r) 8638c2ecf20Sopenharmony_ci{ 8648c2ecf20Sopenharmony_ci unsigned w = r->width; 8658c2ecf20Sopenharmony_ci unsigned h = r->height; 8668c2ecf20Sopenharmony_ci 8678c2ecf20Sopenharmony_ci /* sanitize w and h in case someone passes ~0 as the value */ 8688c2ecf20Sopenharmony_ci w &= 0xffff; 8698c2ecf20Sopenharmony_ci h &= 0xffff; 8708c2ecf20Sopenharmony_ci if (!(flags & V4L2_SEL_FLAG_LE)) { 8718c2ecf20Sopenharmony_ci w++; 8728c2ecf20Sopenharmony_ci h++; 8738c2ecf20Sopenharmony_ci if (w < 2) 8748c2ecf20Sopenharmony_ci w = 2; 8758c2ecf20Sopenharmony_ci if (h < 2) 8768c2ecf20Sopenharmony_ci h = 2; 8778c2ecf20Sopenharmony_ci } 8788c2ecf20Sopenharmony_ci if (!(flags & V4L2_SEL_FLAG_GE)) { 8798c2ecf20Sopenharmony_ci if (w > MAX_WIDTH) 8808c2ecf20Sopenharmony_ci w = MAX_WIDTH; 8818c2ecf20Sopenharmony_ci if (h > MAX_HEIGHT) 8828c2ecf20Sopenharmony_ci h = MAX_HEIGHT; 8838c2ecf20Sopenharmony_ci } 8848c2ecf20Sopenharmony_ci w = w & ~1; 8858c2ecf20Sopenharmony_ci h = h & ~1; 8868c2ecf20Sopenharmony_ci if (w < 2 || h < 2) 8878c2ecf20Sopenharmony_ci return -ERANGE; 8888c2ecf20Sopenharmony_ci if (w > MAX_WIDTH || h > MAX_HEIGHT) 8898c2ecf20Sopenharmony_ci return -ERANGE; 8908c2ecf20Sopenharmony_ci if (r->top < 0) 8918c2ecf20Sopenharmony_ci r->top = 0; 8928c2ecf20Sopenharmony_ci if (r->left < 0) 8938c2ecf20Sopenharmony_ci r->left = 0; 8948c2ecf20Sopenharmony_ci /* sanitize left and top in case someone passes ~0 as the value */ 8958c2ecf20Sopenharmony_ci r->left &= 0xfffe; 8968c2ecf20Sopenharmony_ci r->top &= 0xfffe; 8978c2ecf20Sopenharmony_ci if (r->left + w > MAX_WIDTH) 8988c2ecf20Sopenharmony_ci r->left = MAX_WIDTH - w; 8998c2ecf20Sopenharmony_ci if (r->top + h > MAX_HEIGHT) 9008c2ecf20Sopenharmony_ci r->top = MAX_HEIGHT - h; 9018c2ecf20Sopenharmony_ci if ((flags & (V4L2_SEL_FLAG_GE | V4L2_SEL_FLAG_LE)) == 9028c2ecf20Sopenharmony_ci (V4L2_SEL_FLAG_GE | V4L2_SEL_FLAG_LE) && 9038c2ecf20Sopenharmony_ci (r->width != w || r->height != h)) 9048c2ecf20Sopenharmony_ci return -ERANGE; 9058c2ecf20Sopenharmony_ci r->width = w; 9068c2ecf20Sopenharmony_ci r->height = h; 9078c2ecf20Sopenharmony_ci return 0; 9088c2ecf20Sopenharmony_ci} 9098c2ecf20Sopenharmony_ci 9108c2ecf20Sopenharmony_ciint vivid_enum_fmt_vid(struct file *file, void *priv, 9118c2ecf20Sopenharmony_ci struct v4l2_fmtdesc *f) 9128c2ecf20Sopenharmony_ci{ 9138c2ecf20Sopenharmony_ci struct vivid_dev *dev = video_drvdata(file); 9148c2ecf20Sopenharmony_ci const struct vivid_fmt *fmt; 9158c2ecf20Sopenharmony_ci 9168c2ecf20Sopenharmony_ci if (f->index >= ARRAY_SIZE(vivid_formats) - 9178c2ecf20Sopenharmony_ci (dev->multiplanar ? 0 : VIVID_MPLANAR_FORMATS)) 9188c2ecf20Sopenharmony_ci return -EINVAL; 9198c2ecf20Sopenharmony_ci 9208c2ecf20Sopenharmony_ci fmt = &vivid_formats[f->index]; 9218c2ecf20Sopenharmony_ci 9228c2ecf20Sopenharmony_ci f->pixelformat = fmt->fourcc; 9238c2ecf20Sopenharmony_ci 9248c2ecf20Sopenharmony_ci if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && 9258c2ecf20Sopenharmony_ci f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) 9268c2ecf20Sopenharmony_ci return 0; 9278c2ecf20Sopenharmony_ci /* 9288c2ecf20Sopenharmony_ci * For capture devices, we support the CSC API. 9298c2ecf20Sopenharmony_ci * We allow userspace to: 9308c2ecf20Sopenharmony_ci * 1. set the colorspace 9318c2ecf20Sopenharmony_ci * 2. set the xfer_func 9328c2ecf20Sopenharmony_ci * 3. set the ycbcr_enc on YUV formats 9338c2ecf20Sopenharmony_ci * 4. set the hsv_enc on HSV formats 9348c2ecf20Sopenharmony_ci * 5. set the quantization on YUV and RGB formats 9358c2ecf20Sopenharmony_ci */ 9368c2ecf20Sopenharmony_ci f->flags |= V4L2_FMT_FLAG_CSC_COLORSPACE; 9378c2ecf20Sopenharmony_ci f->flags |= V4L2_FMT_FLAG_CSC_XFER_FUNC; 9388c2ecf20Sopenharmony_ci 9398c2ecf20Sopenharmony_ci if (fmt->color_enc == TGP_COLOR_ENC_YCBCR) { 9408c2ecf20Sopenharmony_ci f->flags |= V4L2_FMT_FLAG_CSC_YCBCR_ENC; 9418c2ecf20Sopenharmony_ci f->flags |= V4L2_FMT_FLAG_CSC_QUANTIZATION; 9428c2ecf20Sopenharmony_ci } else if (fmt->color_enc == TGP_COLOR_ENC_HSV) { 9438c2ecf20Sopenharmony_ci f->flags |= V4L2_FMT_FLAG_CSC_HSV_ENC; 9448c2ecf20Sopenharmony_ci } else if (fmt->color_enc == TGP_COLOR_ENC_RGB) { 9458c2ecf20Sopenharmony_ci f->flags |= V4L2_FMT_FLAG_CSC_QUANTIZATION; 9468c2ecf20Sopenharmony_ci } 9478c2ecf20Sopenharmony_ci 9488c2ecf20Sopenharmony_ci return 0; 9498c2ecf20Sopenharmony_ci} 9508c2ecf20Sopenharmony_ci 9518c2ecf20Sopenharmony_ciint vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id) 9528c2ecf20Sopenharmony_ci{ 9538c2ecf20Sopenharmony_ci struct vivid_dev *dev = video_drvdata(file); 9548c2ecf20Sopenharmony_ci struct video_device *vdev = video_devdata(file); 9558c2ecf20Sopenharmony_ci 9568c2ecf20Sopenharmony_ci if (vdev->vfl_dir == VFL_DIR_RX) { 9578c2ecf20Sopenharmony_ci if (!vivid_is_sdtv_cap(dev)) 9588c2ecf20Sopenharmony_ci return -ENODATA; 9598c2ecf20Sopenharmony_ci *id = dev->std_cap[dev->input]; 9608c2ecf20Sopenharmony_ci } else { 9618c2ecf20Sopenharmony_ci if (!vivid_is_svid_out(dev)) 9628c2ecf20Sopenharmony_ci return -ENODATA; 9638c2ecf20Sopenharmony_ci *id = dev->std_out; 9648c2ecf20Sopenharmony_ci } 9658c2ecf20Sopenharmony_ci return 0; 9668c2ecf20Sopenharmony_ci} 9678c2ecf20Sopenharmony_ci 9688c2ecf20Sopenharmony_ciint vidioc_g_dv_timings(struct file *file, void *_fh, 9698c2ecf20Sopenharmony_ci struct v4l2_dv_timings *timings) 9708c2ecf20Sopenharmony_ci{ 9718c2ecf20Sopenharmony_ci struct vivid_dev *dev = video_drvdata(file); 9728c2ecf20Sopenharmony_ci struct video_device *vdev = video_devdata(file); 9738c2ecf20Sopenharmony_ci 9748c2ecf20Sopenharmony_ci if (vdev->vfl_dir == VFL_DIR_RX) { 9758c2ecf20Sopenharmony_ci if (!vivid_is_hdmi_cap(dev)) 9768c2ecf20Sopenharmony_ci return -ENODATA; 9778c2ecf20Sopenharmony_ci *timings = dev->dv_timings_cap[dev->input]; 9788c2ecf20Sopenharmony_ci } else { 9798c2ecf20Sopenharmony_ci if (!vivid_is_hdmi_out(dev)) 9808c2ecf20Sopenharmony_ci return -ENODATA; 9818c2ecf20Sopenharmony_ci *timings = dev->dv_timings_out; 9828c2ecf20Sopenharmony_ci } 9838c2ecf20Sopenharmony_ci return 0; 9848c2ecf20Sopenharmony_ci} 9858c2ecf20Sopenharmony_ci 9868c2ecf20Sopenharmony_ciint vidioc_enum_dv_timings(struct file *file, void *_fh, 9878c2ecf20Sopenharmony_ci struct v4l2_enum_dv_timings *timings) 9888c2ecf20Sopenharmony_ci{ 9898c2ecf20Sopenharmony_ci struct vivid_dev *dev = video_drvdata(file); 9908c2ecf20Sopenharmony_ci struct video_device *vdev = video_devdata(file); 9918c2ecf20Sopenharmony_ci 9928c2ecf20Sopenharmony_ci if (vdev->vfl_dir == VFL_DIR_RX) { 9938c2ecf20Sopenharmony_ci if (!vivid_is_hdmi_cap(dev)) 9948c2ecf20Sopenharmony_ci return -ENODATA; 9958c2ecf20Sopenharmony_ci } else { 9968c2ecf20Sopenharmony_ci if (!vivid_is_hdmi_out(dev)) 9978c2ecf20Sopenharmony_ci return -ENODATA; 9988c2ecf20Sopenharmony_ci } 9998c2ecf20Sopenharmony_ci return v4l2_enum_dv_timings_cap(timings, &vivid_dv_timings_cap, 10008c2ecf20Sopenharmony_ci NULL, NULL); 10018c2ecf20Sopenharmony_ci} 10028c2ecf20Sopenharmony_ci 10038c2ecf20Sopenharmony_ciint vidioc_dv_timings_cap(struct file *file, void *_fh, 10048c2ecf20Sopenharmony_ci struct v4l2_dv_timings_cap *cap) 10058c2ecf20Sopenharmony_ci{ 10068c2ecf20Sopenharmony_ci struct vivid_dev *dev = video_drvdata(file); 10078c2ecf20Sopenharmony_ci struct video_device *vdev = video_devdata(file); 10088c2ecf20Sopenharmony_ci 10098c2ecf20Sopenharmony_ci if (vdev->vfl_dir == VFL_DIR_RX) { 10108c2ecf20Sopenharmony_ci if (!vivid_is_hdmi_cap(dev)) 10118c2ecf20Sopenharmony_ci return -ENODATA; 10128c2ecf20Sopenharmony_ci } else { 10138c2ecf20Sopenharmony_ci if (!vivid_is_hdmi_out(dev)) 10148c2ecf20Sopenharmony_ci return -ENODATA; 10158c2ecf20Sopenharmony_ci } 10168c2ecf20Sopenharmony_ci *cap = vivid_dv_timings_cap; 10178c2ecf20Sopenharmony_ci return 0; 10188c2ecf20Sopenharmony_ci} 10198c2ecf20Sopenharmony_ci 10208c2ecf20Sopenharmony_ciint vidioc_g_edid(struct file *file, void *_fh, 10218c2ecf20Sopenharmony_ci struct v4l2_edid *edid) 10228c2ecf20Sopenharmony_ci{ 10238c2ecf20Sopenharmony_ci struct vivid_dev *dev = video_drvdata(file); 10248c2ecf20Sopenharmony_ci struct video_device *vdev = video_devdata(file); 10258c2ecf20Sopenharmony_ci struct cec_adapter *adap; 10268c2ecf20Sopenharmony_ci 10278c2ecf20Sopenharmony_ci memset(edid->reserved, 0, sizeof(edid->reserved)); 10288c2ecf20Sopenharmony_ci if (vdev->vfl_dir == VFL_DIR_RX) { 10298c2ecf20Sopenharmony_ci if (edid->pad >= dev->num_inputs) 10308c2ecf20Sopenharmony_ci return -EINVAL; 10318c2ecf20Sopenharmony_ci if (dev->input_type[edid->pad] != HDMI) 10328c2ecf20Sopenharmony_ci return -EINVAL; 10338c2ecf20Sopenharmony_ci adap = dev->cec_rx_adap; 10348c2ecf20Sopenharmony_ci } else { 10358c2ecf20Sopenharmony_ci unsigned int bus_idx; 10368c2ecf20Sopenharmony_ci 10378c2ecf20Sopenharmony_ci if (edid->pad >= dev->num_outputs) 10388c2ecf20Sopenharmony_ci return -EINVAL; 10398c2ecf20Sopenharmony_ci if (dev->output_type[edid->pad] != HDMI) 10408c2ecf20Sopenharmony_ci return -EINVAL; 10418c2ecf20Sopenharmony_ci if (!dev->display_present[edid->pad]) 10428c2ecf20Sopenharmony_ci return -ENODATA; 10438c2ecf20Sopenharmony_ci bus_idx = dev->cec_output2bus_map[edid->pad]; 10448c2ecf20Sopenharmony_ci adap = dev->cec_tx_adap[bus_idx]; 10458c2ecf20Sopenharmony_ci } 10468c2ecf20Sopenharmony_ci if (edid->start_block == 0 && edid->blocks == 0) { 10478c2ecf20Sopenharmony_ci edid->blocks = dev->edid_blocks; 10488c2ecf20Sopenharmony_ci return 0; 10498c2ecf20Sopenharmony_ci } 10508c2ecf20Sopenharmony_ci if (dev->edid_blocks == 0) 10518c2ecf20Sopenharmony_ci return -ENODATA; 10528c2ecf20Sopenharmony_ci if (edid->start_block >= dev->edid_blocks) 10538c2ecf20Sopenharmony_ci return -EINVAL; 10548c2ecf20Sopenharmony_ci if (edid->blocks > dev->edid_blocks - edid->start_block) 10558c2ecf20Sopenharmony_ci edid->blocks = dev->edid_blocks - edid->start_block; 10568c2ecf20Sopenharmony_ci if (adap) 10578c2ecf20Sopenharmony_ci v4l2_set_edid_phys_addr(dev->edid, dev->edid_blocks * 128, adap->phys_addr); 10588c2ecf20Sopenharmony_ci memcpy(edid->edid, dev->edid + edid->start_block * 128, edid->blocks * 128); 10598c2ecf20Sopenharmony_ci return 0; 10608c2ecf20Sopenharmony_ci} 1061