18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * vsp1_pipe.c -- R-Car VSP1 Pipeline 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2013-2015 Renesas Electronics Corporation 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/delay.h> 118c2ecf20Sopenharmony_ci#include <linux/list.h> 128c2ecf20Sopenharmony_ci#include <linux/sched.h> 138c2ecf20Sopenharmony_ci#include <linux/wait.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <media/media-entity.h> 168c2ecf20Sopenharmony_ci#include <media/v4l2-subdev.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include "vsp1.h" 198c2ecf20Sopenharmony_ci#include "vsp1_brx.h" 208c2ecf20Sopenharmony_ci#include "vsp1_dl.h" 218c2ecf20Sopenharmony_ci#include "vsp1_entity.h" 228c2ecf20Sopenharmony_ci#include "vsp1_hgo.h" 238c2ecf20Sopenharmony_ci#include "vsp1_hgt.h" 248c2ecf20Sopenharmony_ci#include "vsp1_pipe.h" 258c2ecf20Sopenharmony_ci#include "vsp1_rwpf.h" 268c2ecf20Sopenharmony_ci#include "vsp1_uds.h" 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* ----------------------------------------------------------------------------- 298c2ecf20Sopenharmony_ci * Helper Functions 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistatic const struct vsp1_format_info vsp1_video_formats[] = { 338c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_RGB332, MEDIA_BUS_FMT_ARGB8888_1X32, 348c2ecf20Sopenharmony_ci VI6_FMT_RGB_332, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 358c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 368c2ecf20Sopenharmony_ci 1, { 8, 0, 0 }, false, false, 1, 1, false }, 378c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_ARGB444, MEDIA_BUS_FMT_ARGB8888_1X32, 388c2ecf20Sopenharmony_ci VI6_FMT_ARGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 398c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 408c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, true }, 418c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_XRGB444, MEDIA_BUS_FMT_ARGB8888_1X32, 428c2ecf20Sopenharmony_ci VI6_FMT_XRGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 438c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 448c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, false }, 458c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_RGBA444, MEDIA_BUS_FMT_ARGB8888_1X32, 468c2ecf20Sopenharmony_ci VI6_FMT_RGBA_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 478c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 488c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, true }, 498c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_RGBX444, MEDIA_BUS_FMT_ARGB8888_1X32, 508c2ecf20Sopenharmony_ci VI6_FMT_RGBX_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 518c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 528c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, false }, 538c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_ABGR444, MEDIA_BUS_FMT_ARGB8888_1X32, 548c2ecf20Sopenharmony_ci VI6_FMT_ABGR_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 558c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 568c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, true }, 578c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_XBGR444, MEDIA_BUS_FMT_ARGB8888_1X32, 588c2ecf20Sopenharmony_ci VI6_FMT_ABGR_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 598c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 608c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, false }, 618c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_BGRA444, MEDIA_BUS_FMT_ARGB8888_1X32, 628c2ecf20Sopenharmony_ci VI6_FMT_BGRA_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 638c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 648c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, true }, 658c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_BGRX444, MEDIA_BUS_FMT_ARGB8888_1X32, 668c2ecf20Sopenharmony_ci VI6_FMT_BGRA_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 678c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 688c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, false }, 698c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_ARGB555, MEDIA_BUS_FMT_ARGB8888_1X32, 708c2ecf20Sopenharmony_ci VI6_FMT_ARGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 718c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 728c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, true }, 738c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_XRGB555, MEDIA_BUS_FMT_ARGB8888_1X32, 748c2ecf20Sopenharmony_ci VI6_FMT_XRGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 758c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 768c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, false }, 778c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_RGBA555, MEDIA_BUS_FMT_ARGB8888_1X32, 788c2ecf20Sopenharmony_ci VI6_FMT_RGBA_5551, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 798c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 808c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, true }, 818c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_RGBX555, MEDIA_BUS_FMT_ARGB8888_1X32, 828c2ecf20Sopenharmony_ci VI6_FMT_RGBX_5551, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 838c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 848c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, false }, 858c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_ABGR555, MEDIA_BUS_FMT_ARGB8888_1X32, 868c2ecf20Sopenharmony_ci VI6_FMT_ABGR_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 878c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 888c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, true }, 898c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_XBGR555, MEDIA_BUS_FMT_ARGB8888_1X32, 908c2ecf20Sopenharmony_ci VI6_FMT_ABGR_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 918c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 928c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, false }, 938c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_BGRA555, MEDIA_BUS_FMT_ARGB8888_1X32, 948c2ecf20Sopenharmony_ci VI6_FMT_BGRA_5551, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 958c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 968c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, true }, 978c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_BGRX555, MEDIA_BUS_FMT_ARGB8888_1X32, 988c2ecf20Sopenharmony_ci VI6_FMT_BGRA_5551, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 998c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 1008c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, false }, 1018c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_RGB565, MEDIA_BUS_FMT_ARGB8888_1X32, 1028c2ecf20Sopenharmony_ci VI6_FMT_RGB_565, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1038c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS, 1048c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 1, 1, false }, 1058c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_BGR24, MEDIA_BUS_FMT_ARGB8888_1X32, 1068c2ecf20Sopenharmony_ci VI6_FMT_BGR_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1078c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1088c2ecf20Sopenharmony_ci 1, { 24, 0, 0 }, false, false, 1, 1, false }, 1098c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_RGB24, MEDIA_BUS_FMT_ARGB8888_1X32, 1108c2ecf20Sopenharmony_ci VI6_FMT_RGB_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1118c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1128c2ecf20Sopenharmony_ci 1, { 24, 0, 0 }, false, false, 1, 1, false }, 1138c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_ABGR32, MEDIA_BUS_FMT_ARGB8888_1X32, 1148c2ecf20Sopenharmony_ci VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS, 1158c2ecf20Sopenharmony_ci 1, { 32, 0, 0 }, false, false, 1, 1, true }, 1168c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_XBGR32, MEDIA_BUS_FMT_ARGB8888_1X32, 1178c2ecf20Sopenharmony_ci VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS, 1188c2ecf20Sopenharmony_ci 1, { 32, 0, 0 }, false, false, 1, 1, false }, 1198c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_BGRA32, MEDIA_BUS_FMT_ARGB8888_1X32, 1208c2ecf20Sopenharmony_ci VI6_FMT_RGBA_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS, 1218c2ecf20Sopenharmony_ci 1, { 32, 0, 0 }, false, false, 1, 1, true }, 1228c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_BGRX32, MEDIA_BUS_FMT_ARGB8888_1X32, 1238c2ecf20Sopenharmony_ci VI6_FMT_RGBA_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS, 1248c2ecf20Sopenharmony_ci 1, { 32, 0, 0 }, false, false, 1, 1, false }, 1258c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_RGBA32, MEDIA_BUS_FMT_ARGB8888_1X32, 1268c2ecf20Sopenharmony_ci VI6_FMT_RGBA_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1278c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1288c2ecf20Sopenharmony_ci 1, { 32, 0, 0 }, false, false, 1, 1, true }, 1298c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_RGBX32, MEDIA_BUS_FMT_ARGB8888_1X32, 1308c2ecf20Sopenharmony_ci VI6_FMT_RGBA_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1318c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1328c2ecf20Sopenharmony_ci 1, { 32, 0, 0 }, false, false, 1, 1, false }, 1338c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_ARGB32, MEDIA_BUS_FMT_ARGB8888_1X32, 1348c2ecf20Sopenharmony_ci VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1358c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1368c2ecf20Sopenharmony_ci 1, { 32, 0, 0 }, false, false, 1, 1, true }, 1378c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_XRGB32, MEDIA_BUS_FMT_ARGB8888_1X32, 1388c2ecf20Sopenharmony_ci VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1398c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1408c2ecf20Sopenharmony_ci 1, { 32, 0, 0 }, false, false, 1, 1, false }, 1418c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_HSV24, MEDIA_BUS_FMT_AHSV8888_1X32, 1428c2ecf20Sopenharmony_ci VI6_FMT_RGB_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1438c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1448c2ecf20Sopenharmony_ci 1, { 24, 0, 0 }, false, false, 1, 1, false }, 1458c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_HSV32, MEDIA_BUS_FMT_AHSV8888_1X32, 1468c2ecf20Sopenharmony_ci VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1478c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1488c2ecf20Sopenharmony_ci 1, { 32, 0, 0 }, false, false, 1, 1, false }, 1498c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_UYVY, MEDIA_BUS_FMT_AYUV8_1X32, 1508c2ecf20Sopenharmony_ci VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1518c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1528c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, false, 2, 1, false }, 1538c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_VYUY, MEDIA_BUS_FMT_AYUV8_1X32, 1548c2ecf20Sopenharmony_ci VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1558c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1568c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, false, true, 2, 1, false }, 1578c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_YUYV, MEDIA_BUS_FMT_AYUV8_1X32, 1588c2ecf20Sopenharmony_ci VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1598c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1608c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, true, false, 2, 1, false }, 1618c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_YVYU, MEDIA_BUS_FMT_AYUV8_1X32, 1628c2ecf20Sopenharmony_ci VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1638c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1648c2ecf20Sopenharmony_ci 1, { 16, 0, 0 }, true, true, 2, 1, false }, 1658c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_NV12M, MEDIA_BUS_FMT_AYUV8_1X32, 1668c2ecf20Sopenharmony_ci VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1678c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1688c2ecf20Sopenharmony_ci 2, { 8, 16, 0 }, false, false, 2, 2, false }, 1698c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_NV21M, MEDIA_BUS_FMT_AYUV8_1X32, 1708c2ecf20Sopenharmony_ci VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1718c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1728c2ecf20Sopenharmony_ci 2, { 8, 16, 0 }, false, true, 2, 2, false }, 1738c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_NV16M, MEDIA_BUS_FMT_AYUV8_1X32, 1748c2ecf20Sopenharmony_ci VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1758c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1768c2ecf20Sopenharmony_ci 2, { 8, 16, 0 }, false, false, 2, 1, false }, 1778c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_NV61M, MEDIA_BUS_FMT_AYUV8_1X32, 1788c2ecf20Sopenharmony_ci VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1798c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1808c2ecf20Sopenharmony_ci 2, { 8, 16, 0 }, false, true, 2, 1, false }, 1818c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_YUV420M, MEDIA_BUS_FMT_AYUV8_1X32, 1828c2ecf20Sopenharmony_ci VI6_FMT_Y_U_V_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1838c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1848c2ecf20Sopenharmony_ci 3, { 8, 8, 8 }, false, false, 2, 2, false }, 1858c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_YVU420M, MEDIA_BUS_FMT_AYUV8_1X32, 1868c2ecf20Sopenharmony_ci VI6_FMT_Y_U_V_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1878c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1888c2ecf20Sopenharmony_ci 3, { 8, 8, 8 }, false, true, 2, 2, false }, 1898c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_YUV422M, MEDIA_BUS_FMT_AYUV8_1X32, 1908c2ecf20Sopenharmony_ci VI6_FMT_Y_U_V_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1918c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1928c2ecf20Sopenharmony_ci 3, { 8, 8, 8 }, false, false, 2, 1, false }, 1938c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_YVU422M, MEDIA_BUS_FMT_AYUV8_1X32, 1948c2ecf20Sopenharmony_ci VI6_FMT_Y_U_V_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1958c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 1968c2ecf20Sopenharmony_ci 3, { 8, 8, 8 }, false, true, 2, 1, false }, 1978c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_YUV444M, MEDIA_BUS_FMT_AYUV8_1X32, 1988c2ecf20Sopenharmony_ci VI6_FMT_Y_U_V_444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 1998c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 2008c2ecf20Sopenharmony_ci 3, { 8, 8, 8 }, false, false, 1, 1, false }, 2018c2ecf20Sopenharmony_ci { V4L2_PIX_FMT_YVU444M, MEDIA_BUS_FMT_AYUV8_1X32, 2028c2ecf20Sopenharmony_ci VI6_FMT_Y_U_V_444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS | 2038c2ecf20Sopenharmony_ci VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS, 2048c2ecf20Sopenharmony_ci 3, { 8, 8, 8 }, false, true, 1, 1, false }, 2058c2ecf20Sopenharmony_ci}; 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci/** 2088c2ecf20Sopenharmony_ci * vsp1_get_format_info - Retrieve format information for a 4CC 2098c2ecf20Sopenharmony_ci * @vsp1: the VSP1 device 2108c2ecf20Sopenharmony_ci * @fourcc: the format 4CC 2118c2ecf20Sopenharmony_ci * 2128c2ecf20Sopenharmony_ci * Return a pointer to the format information structure corresponding to the 2138c2ecf20Sopenharmony_ci * given V4L2 format 4CC, or NULL if no corresponding format can be found. 2148c2ecf20Sopenharmony_ci */ 2158c2ecf20Sopenharmony_ciconst struct vsp1_format_info *vsp1_get_format_info(struct vsp1_device *vsp1, 2168c2ecf20Sopenharmony_ci u32 fourcc) 2178c2ecf20Sopenharmony_ci{ 2188c2ecf20Sopenharmony_ci unsigned int i; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci /* Special case, the VYUY and HSV formats are supported on Gen2 only. */ 2218c2ecf20Sopenharmony_ci if (vsp1->info->gen != 2) { 2228c2ecf20Sopenharmony_ci switch (fourcc) { 2238c2ecf20Sopenharmony_ci case V4L2_PIX_FMT_VYUY: 2248c2ecf20Sopenharmony_ci case V4L2_PIX_FMT_HSV24: 2258c2ecf20Sopenharmony_ci case V4L2_PIX_FMT_HSV32: 2268c2ecf20Sopenharmony_ci return NULL; 2278c2ecf20Sopenharmony_ci } 2288c2ecf20Sopenharmony_ci } 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(vsp1_video_formats); ++i) { 2318c2ecf20Sopenharmony_ci const struct vsp1_format_info *info = &vsp1_video_formats[i]; 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci if (info->fourcc == fourcc) 2348c2ecf20Sopenharmony_ci return info; 2358c2ecf20Sopenharmony_ci } 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci return NULL; 2388c2ecf20Sopenharmony_ci} 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci/* ----------------------------------------------------------------------------- 2418c2ecf20Sopenharmony_ci * Pipeline Management 2428c2ecf20Sopenharmony_ci */ 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_civoid vsp1_pipeline_reset(struct vsp1_pipeline *pipe) 2458c2ecf20Sopenharmony_ci{ 2468c2ecf20Sopenharmony_ci struct vsp1_entity *entity; 2478c2ecf20Sopenharmony_ci unsigned int i; 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci if (pipe->brx) { 2508c2ecf20Sopenharmony_ci struct vsp1_brx *brx = to_brx(&pipe->brx->subdev); 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(brx->inputs); ++i) 2538c2ecf20Sopenharmony_ci brx->inputs[i].rpf = NULL; 2548c2ecf20Sopenharmony_ci } 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i) 2578c2ecf20Sopenharmony_ci pipe->inputs[i] = NULL; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci pipe->output = NULL; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci list_for_each_entry(entity, &pipe->entities, list_pipe) 2628c2ecf20Sopenharmony_ci entity->pipe = NULL; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&pipe->entities); 2658c2ecf20Sopenharmony_ci pipe->state = VSP1_PIPELINE_STOPPED; 2668c2ecf20Sopenharmony_ci pipe->buffers_ready = 0; 2678c2ecf20Sopenharmony_ci pipe->num_inputs = 0; 2688c2ecf20Sopenharmony_ci pipe->brx = NULL; 2698c2ecf20Sopenharmony_ci pipe->hgo = NULL; 2708c2ecf20Sopenharmony_ci pipe->hgt = NULL; 2718c2ecf20Sopenharmony_ci pipe->lif = NULL; 2728c2ecf20Sopenharmony_ci pipe->uds = NULL; 2738c2ecf20Sopenharmony_ci} 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_civoid vsp1_pipeline_init(struct vsp1_pipeline *pipe) 2768c2ecf20Sopenharmony_ci{ 2778c2ecf20Sopenharmony_ci mutex_init(&pipe->lock); 2788c2ecf20Sopenharmony_ci spin_lock_init(&pipe->irqlock); 2798c2ecf20Sopenharmony_ci init_waitqueue_head(&pipe->wq); 2808c2ecf20Sopenharmony_ci kref_init(&pipe->kref); 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&pipe->entities); 2838c2ecf20Sopenharmony_ci pipe->state = VSP1_PIPELINE_STOPPED; 2848c2ecf20Sopenharmony_ci} 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci/* Must be called with the pipe irqlock held. */ 2878c2ecf20Sopenharmony_civoid vsp1_pipeline_run(struct vsp1_pipeline *pipe) 2888c2ecf20Sopenharmony_ci{ 2898c2ecf20Sopenharmony_ci struct vsp1_device *vsp1 = pipe->output->entity.vsp1; 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci if (pipe->state == VSP1_PIPELINE_STOPPED) { 2928c2ecf20Sopenharmony_ci vsp1_write(vsp1, VI6_CMD(pipe->output->entity.index), 2938c2ecf20Sopenharmony_ci VI6_CMD_STRCMD); 2948c2ecf20Sopenharmony_ci pipe->state = VSP1_PIPELINE_RUNNING; 2958c2ecf20Sopenharmony_ci } 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci pipe->buffers_ready = 0; 2988c2ecf20Sopenharmony_ci} 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_cibool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe) 3018c2ecf20Sopenharmony_ci{ 3028c2ecf20Sopenharmony_ci unsigned long flags; 3038c2ecf20Sopenharmony_ci bool stopped; 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci spin_lock_irqsave(&pipe->irqlock, flags); 3068c2ecf20Sopenharmony_ci stopped = pipe->state == VSP1_PIPELINE_STOPPED; 3078c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&pipe->irqlock, flags); 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci return stopped; 3108c2ecf20Sopenharmony_ci} 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ciint vsp1_pipeline_stop(struct vsp1_pipeline *pipe) 3138c2ecf20Sopenharmony_ci{ 3148c2ecf20Sopenharmony_ci struct vsp1_device *vsp1 = pipe->output->entity.vsp1; 3158c2ecf20Sopenharmony_ci struct vsp1_entity *entity; 3168c2ecf20Sopenharmony_ci unsigned long flags; 3178c2ecf20Sopenharmony_ci int ret; 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci if (pipe->lif) { 3208c2ecf20Sopenharmony_ci /* 3218c2ecf20Sopenharmony_ci * When using display lists in continuous frame mode the only 3228c2ecf20Sopenharmony_ci * way to stop the pipeline is to reset the hardware. 3238c2ecf20Sopenharmony_ci */ 3248c2ecf20Sopenharmony_ci ret = vsp1_reset_wpf(vsp1, pipe->output->entity.index); 3258c2ecf20Sopenharmony_ci if (ret == 0) { 3268c2ecf20Sopenharmony_ci spin_lock_irqsave(&pipe->irqlock, flags); 3278c2ecf20Sopenharmony_ci pipe->state = VSP1_PIPELINE_STOPPED; 3288c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&pipe->irqlock, flags); 3298c2ecf20Sopenharmony_ci } 3308c2ecf20Sopenharmony_ci } else { 3318c2ecf20Sopenharmony_ci /* Otherwise just request a stop and wait. */ 3328c2ecf20Sopenharmony_ci spin_lock_irqsave(&pipe->irqlock, flags); 3338c2ecf20Sopenharmony_ci if (pipe->state == VSP1_PIPELINE_RUNNING) 3348c2ecf20Sopenharmony_ci pipe->state = VSP1_PIPELINE_STOPPING; 3358c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&pipe->irqlock, flags); 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe), 3388c2ecf20Sopenharmony_ci msecs_to_jiffies(500)); 3398c2ecf20Sopenharmony_ci ret = ret == 0 ? -ETIMEDOUT : 0; 3408c2ecf20Sopenharmony_ci } 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_ci list_for_each_entry(entity, &pipe->entities, list_pipe) { 3438c2ecf20Sopenharmony_ci if (entity->route && entity->route->reg) 3448c2ecf20Sopenharmony_ci vsp1_write(vsp1, entity->route->reg, 3458c2ecf20Sopenharmony_ci VI6_DPR_NODE_UNUSED); 3468c2ecf20Sopenharmony_ci } 3478c2ecf20Sopenharmony_ci 3488c2ecf20Sopenharmony_ci if (pipe->hgo) 3498c2ecf20Sopenharmony_ci vsp1_write(vsp1, VI6_DPR_HGO_SMPPT, 3508c2ecf20Sopenharmony_ci (7 << VI6_DPR_SMPPT_TGW_SHIFT) | 3518c2ecf20Sopenharmony_ci (VI6_DPR_NODE_UNUSED << VI6_DPR_SMPPT_PT_SHIFT)); 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci if (pipe->hgt) 3548c2ecf20Sopenharmony_ci vsp1_write(vsp1, VI6_DPR_HGT_SMPPT, 3558c2ecf20Sopenharmony_ci (7 << VI6_DPR_SMPPT_TGW_SHIFT) | 3568c2ecf20Sopenharmony_ci (VI6_DPR_NODE_UNUSED << VI6_DPR_SMPPT_PT_SHIFT)); 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ci v4l2_subdev_call(&pipe->output->entity.subdev, video, s_stream, 0); 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci return ret; 3618c2ecf20Sopenharmony_ci} 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_cibool vsp1_pipeline_ready(struct vsp1_pipeline *pipe) 3648c2ecf20Sopenharmony_ci{ 3658c2ecf20Sopenharmony_ci unsigned int mask; 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci mask = ((1 << pipe->num_inputs) - 1) << 1; 3688c2ecf20Sopenharmony_ci if (!pipe->lif) 3698c2ecf20Sopenharmony_ci mask |= 1 << 0; 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci return pipe->buffers_ready == mask; 3728c2ecf20Sopenharmony_ci} 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_civoid vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe) 3758c2ecf20Sopenharmony_ci{ 3768c2ecf20Sopenharmony_ci unsigned int flags; 3778c2ecf20Sopenharmony_ci 3788c2ecf20Sopenharmony_ci if (pipe == NULL) 3798c2ecf20Sopenharmony_ci return; 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci /* 3828c2ecf20Sopenharmony_ci * If the DL commit raced with the frame end interrupt, the commit ends 3838c2ecf20Sopenharmony_ci * up being postponed by one frame. The returned flags tell whether the 3848c2ecf20Sopenharmony_ci * active frame was finished or postponed. 3858c2ecf20Sopenharmony_ci */ 3868c2ecf20Sopenharmony_ci flags = vsp1_dlm_irq_frame_end(pipe->output->dlm); 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci if (pipe->hgo) 3898c2ecf20Sopenharmony_ci vsp1_hgo_frame_end(pipe->hgo); 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci if (pipe->hgt) 3928c2ecf20Sopenharmony_ci vsp1_hgt_frame_end(pipe->hgt); 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci /* 3958c2ecf20Sopenharmony_ci * Regardless of frame completion we still need to notify the pipe 3968c2ecf20Sopenharmony_ci * frame_end to account for vblank events. 3978c2ecf20Sopenharmony_ci */ 3988c2ecf20Sopenharmony_ci if (pipe->frame_end) 3998c2ecf20Sopenharmony_ci pipe->frame_end(pipe, flags); 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci pipe->sequence++; 4028c2ecf20Sopenharmony_ci} 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_ci/* 4058c2ecf20Sopenharmony_ci * Propagate the alpha value through the pipeline. 4068c2ecf20Sopenharmony_ci * 4078c2ecf20Sopenharmony_ci * As the UDS has restricted scaling capabilities when the alpha component needs 4088c2ecf20Sopenharmony_ci * to be scaled, we disable alpha scaling when the UDS input has a fixed alpha 4098c2ecf20Sopenharmony_ci * value. The UDS then outputs a fixed alpha value which needs to be programmed 4108c2ecf20Sopenharmony_ci * from the input RPF alpha. 4118c2ecf20Sopenharmony_ci */ 4128c2ecf20Sopenharmony_civoid vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe, 4138c2ecf20Sopenharmony_ci struct vsp1_dl_body *dlb, unsigned int alpha) 4148c2ecf20Sopenharmony_ci{ 4158c2ecf20Sopenharmony_ci if (!pipe->uds) 4168c2ecf20Sopenharmony_ci return; 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci /* 4198c2ecf20Sopenharmony_ci * The BRU and BRS background color has a fixed alpha value set to 255, 4208c2ecf20Sopenharmony_ci * the output alpha value is thus always equal to 255. 4218c2ecf20Sopenharmony_ci */ 4228c2ecf20Sopenharmony_ci if (pipe->uds_input->type == VSP1_ENTITY_BRU || 4238c2ecf20Sopenharmony_ci pipe->uds_input->type == VSP1_ENTITY_BRS) 4248c2ecf20Sopenharmony_ci alpha = 255; 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ci vsp1_uds_set_alpha(pipe->uds, dlb, alpha); 4278c2ecf20Sopenharmony_ci} 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ci/* 4308c2ecf20Sopenharmony_ci * Propagate the partition calculations through the pipeline 4318c2ecf20Sopenharmony_ci * 4328c2ecf20Sopenharmony_ci * Work backwards through the pipe, allowing each entity to update the partition 4338c2ecf20Sopenharmony_ci * parameters based on its configuration, and the entity connected to its 4348c2ecf20Sopenharmony_ci * source. Each entity must produce the partition required for the previous 4358c2ecf20Sopenharmony_ci * entity in the pipeline. 4368c2ecf20Sopenharmony_ci */ 4378c2ecf20Sopenharmony_civoid vsp1_pipeline_propagate_partition(struct vsp1_pipeline *pipe, 4388c2ecf20Sopenharmony_ci struct vsp1_partition *partition, 4398c2ecf20Sopenharmony_ci unsigned int index, 4408c2ecf20Sopenharmony_ci struct vsp1_partition_window *window) 4418c2ecf20Sopenharmony_ci{ 4428c2ecf20Sopenharmony_ci struct vsp1_entity *entity; 4438c2ecf20Sopenharmony_ci 4448c2ecf20Sopenharmony_ci list_for_each_entry_reverse(entity, &pipe->entities, list_pipe) { 4458c2ecf20Sopenharmony_ci if (entity->ops->partition) 4468c2ecf20Sopenharmony_ci entity->ops->partition(entity, pipe, partition, index, 4478c2ecf20Sopenharmony_ci window); 4488c2ecf20Sopenharmony_ci } 4498c2ecf20Sopenharmony_ci} 4508c2ecf20Sopenharmony_ci 451