FILE
imx8-isi-gasket.c
File preview with syntax highlighting.
linux-6.19.14/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright 2019-2023 NXP 4 */ 5 6#include <linux/bitfield.h> 7#include <linux/bits.h> 8#include <linux/regmap.h> 9 10#include <media/mipi-csi2.h> 11 12#include "imx8-isi-core.h" 13 14/* ----------------------------------------------------------------------------- 15 * i.MX8MN and i.MX8MP gasket 16 */ 17 18#define GASKET_BASE(n) (0x0060 + (n) * 0x30) 19 20#define GASKET_CTRL 0x0000 21#define GASKET_CTRL_DATA_TYPE(dt) FIELD_PREP(GENMASK(13, 8), dt) 22#define GASKET_CTRL_DUAL_COMP_ENABLE BIT(1) 23#define GASKET_CTRL_ENABLE BIT(0) 24 25#define GASKET_HSIZE 0x0004 26#define GASKET_VSIZE 0x0008 27 28static void mxc_imx8_gasket_enable(struct mxc_isi_dev *isi, 29 const struct v4l2_mbus_frame_desc *fd, 30 const struct v4l2_mbus_framefmt *fmt, 31 const unsigned int port) 32{ 33 u32 val; 34 35 regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_HSIZE, fmt->width); 36 regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_VSIZE, fmt->height); 37 38 val = GASKET_CTRL_DATA_TYPE(fd->entry[0].bus.csi2.dt); 39 if (fd->entry[0].bus.csi2.dt == MIPI_CSI2_DT_YUV422_8B) 40 val |= GASKET_CTRL_DUAL_COMP_ENABLE; 41 42 val |= GASKET_CTRL_ENABLE; 43 regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, val); 44} 45 46static void mxc_imx8_gasket_disable(struct mxc_isi_dev *isi, 47 const unsigned int port) 48{ 49 regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, 0); 50} 51 52const struct mxc_gasket_ops mxc_imx8_gasket_ops = { 53 .enable = mxc_imx8_gasket_enable, 54 .disable = mxc_imx8_gasket_disable, 55}; 56 57/* ----------------------------------------------------------------------------- 58 * i.MX93 gasket 59 */ 60 61#define DISP_MIX_CAMERA_MUX 0x30 62#define DISP_MIX_CAMERA_MUX_DATA_TYPE(x) FIELD_PREP(GENMASK(8, 3), x) 63#define DISP_MIX_CAMERA_MUX_GASKET_ENABLE BIT(16) 64#define DISP_MIX_CAMERA_MUX_GASKET_SOURCE_TYPE BIT(17) 65 66static void mxc_imx93_gasket_enable(struct mxc_isi_dev *isi, 67 const struct v4l2_mbus_frame_desc *fd, 68 const struct v4l2_mbus_framefmt *fmt, 69 const unsigned int port) 70{ 71 u32 val; 72 73 val = DISP_MIX_CAMERA_MUX_DATA_TYPE(fd->entry[0].bus.csi2.dt); 74 val |= DISP_MIX_CAMERA_MUX_GASKET_ENABLE; 75 76 /* 77 * CAMERA MUX 78 * - [17]: Selects source input to gasket 79 * 0: Data from MIPI CSI 80 * 1: Data from parallel camera 81 */ 82 if (fd->type == V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL) 83 val |= DISP_MIX_CAMERA_MUX_GASKET_SOURCE_TYPE; 84 85 regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, val); 86} 87 88static void mxc_imx93_gasket_disable(struct mxc_isi_dev *isi, 89 unsigned int port) 90{ 91 regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, 0); 92} 93 94const struct mxc_gasket_ops mxc_imx93_gasket_ops = { 95 .enable = mxc_imx93_gasket_enable, 96 .disable = mxc_imx93_gasket_disable, 97};
~/
Read-only file preview.