Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da16e44a authored by Alan Kwong's avatar Alan Kwong Committed by Narendra Muppalla
Browse files

msm: sde: add format enumeration based on rotator version



Current pixel format enumeration reports pixel format supported
by driver, and may include formats not supported by underlying
hardware.  This patch reorganizes pixel format enumeration to
report hardware supported pixel formats based on hardware version
as well I/O port direction.

CRs-Fixed: 1054825
Change-Id: I1e42b11b43f69dba4a5ac68cfdfb8305136a307c
Signed-off-by: default avatarAlan Kwong <akwong@codeaurora.org>
parent fb6faa30
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1273,8 +1273,13 @@ static bool sde_rotator_verify_format(struct sde_rot_mgr *mgr,
	u8 in_v_subsample, in_h_subsample;
	u8 out_v_subsample, out_h_subsample;

	if (!sde_mdp_is_wb_format(out_fmt)) {
		SDEROT_DBG("Invalid output format\n");
	if (!sde_rotator_is_valid_pixfmt(mgr, in_fmt->format, true)) {
		SDEROT_DBG("Invalid input format %x\n", in_fmt->format);
		return false;
	}

	if (!sde_rotator_is_valid_pixfmt(mgr, out_fmt->format, false)) {
		SDEROT_DBG("Invalid output format %x\n", out_fmt->format);
		return false;
	}

+22 −0
Original line number Diff line number Diff line
@@ -302,10 +302,32 @@ struct sde_rot_mgr {
			struct dentry *debugfs_root);
	int (*ops_hw_validate_entry)(struct sde_rot_mgr *mgr,
			struct sde_rot_entry *entry);
	u32 (*ops_hw_get_pixfmt)(struct sde_rot_mgr *mgr, int index,
			bool input);
	int (*ops_hw_is_valid_pixfmt)(struct sde_rot_mgr *mgr, u32 pixfmt,
			bool input);

	void *hw_data;
};

static inline int sde_rotator_is_valid_pixfmt(struct sde_rot_mgr *mgr,
		u32 pixfmt, bool input)
{
	if (mgr && mgr->ops_hw_is_valid_pixfmt)
		return mgr->ops_hw_is_valid_pixfmt(mgr, pixfmt, input);

	return false;
}

static inline u32 sde_rotator_get_pixfmt(struct sde_rot_mgr *mgr,
		int index, bool input)
{
	if (mgr && mgr->ops_hw_get_pixfmt)
		return mgr->ops_hw_get_pixfmt(mgr, index, input);

	return 0;
}

static inline int __compare_session_item_rect(
	struct sde_rotation_buf_info *s_rect,
	struct sde_rect *i_rect, uint32_t i_fmt, bool src)
+26 −276
Original line number Diff line number Diff line
@@ -52,244 +52,6 @@
#define SDE_ROTATOR_DEGREE_270		270
#define SDE_ROTATOR_DEGREE_180		180
#define SDE_ROTATOR_DEGREE_90		90
/*
 * Format description/mapping
 * @pixelformat: external format defined in msm_sde_rotator header.
 *
 * Note RGBA/8888 naming convention follows internal convention and
 * is reverse of standard V4L2 convention.  Description containing
 * prefix 'SDE/' refers to SDE specific conventions and/or features.
 */
static const struct v4l2_fmtdesc fmtdesc[] = {
	{
		.description = "SDE/XRGB_8888",
		.pixelformat = SDE_PIX_FMT_XRGB_8888,
	},
	{
		.description = "SDE/ARGB_8888",
		.pixelformat = SDE_PIX_FMT_ARGB_8888,
	},
	{
		.description = "SDE/ABGR_8888",
		.pixelformat = SDE_PIX_FMT_ABGR_8888,
	},
	{
		.description = "SDE/RGBA_8888",
		.pixelformat = SDE_PIX_FMT_RGBA_8888,
	},
	{
		.description = "SDE/BGRA_8888",
		.pixelformat = SDE_PIX_FMT_BGRA_8888,
	},
	{
		.description = "SDE/RGBX_8888",
		.pixelformat = SDE_PIX_FMT_RGBX_8888,
	},
	{
		.description = "SDE/BGRX_8888",
		.pixelformat = SDE_PIX_FMT_BGRX_8888,
	},
	{
		.description = "SDE/XBGR_8888",
		.pixelformat = SDE_PIX_FMT_XBGR_8888,
	},
	{
		.description = "RGBA_5551",
		.pixelformat = SDE_PIX_FMT_RGBA_5551,
	},
	{
		.description = "ARGB_1555",
		.pixelformat = SDE_PIX_FMT_ARGB_1555,
	},
	{
		.description = "ABGR_1555",
		.pixelformat = SDE_PIX_FMT_ABGR_1555,
	},
	{
		.description = "BGRA_5551",
		.pixelformat = SDE_PIX_FMT_BGRA_5551,
	},
	{
		.description = "BGRX_5551",
		.pixelformat = SDE_PIX_FMT_BGRX_5551,
	},
	{
		.description = "RGBX_5551",
		.pixelformat = SDE_PIX_FMT_RGBX_5551,
	},
	{
		.description = "XBGR_1555",
		.pixelformat = SDE_PIX_FMT_XBGR_1555,
	},
	{
		.description = "XRGB_1555",
		.pixelformat = SDE_PIX_FMT_XRGB_1555,
	},
	{
		.description = "ARGB_4444",
		.pixelformat = SDE_PIX_FMT_ARGB_4444,
	},
	{
		.description = "RGBA_4444",
		.pixelformat = SDE_PIX_FMT_RGBA_4444,
	},
	{
		.description = "BGRA_4444",
		.pixelformat = SDE_PIX_FMT_BGRA_4444,
	},
	{
		.description = "ABGR_4444",
		.pixelformat = SDE_PIX_FMT_ABGR_4444,
	},
	{
		.description = "RGBX_4444",
		.pixelformat = SDE_PIX_FMT_RGBX_4444,
	},
	{
		.description = "XRGB_4444",
		.pixelformat = SDE_PIX_FMT_XRGB_4444,
	},
	{
		.description = "BGRX_4444",
		.pixelformat = SDE_PIX_FMT_BGRX_4444,
	},
	{
		.description = "XBGR_4444",
		.pixelformat = SDE_PIX_FMT_XBGR_4444,
	},
	{
		.description = "RGB_888",
		.pixelformat = SDE_PIX_FMT_RGB_888,
	},
	{
		.description = "BGR_888",
		.pixelformat = SDE_PIX_FMT_BGR_888,
	},
	{
		.description = "RGB_565",
		.pixelformat = SDE_PIX_FMT_RGB_565,
	},
	{
		.description = "BGR_565",
		.pixelformat = SDE_PIX_FMT_BGR_565,
	},
	{
		.description = "Y_CB_CR_H2V2",
		.pixelformat = SDE_PIX_FMT_Y_CB_CR_H2V2,
	},
	{
		.description = "Y_CR_CB_H2V2",
		.pixelformat = SDE_PIX_FMT_Y_CR_CB_H2V2,
	},
	{
		.description = "SDE/Y_CR_CB_GH2V2",
		.pixelformat = SDE_PIX_FMT_Y_CR_CB_GH2V2,
	},
	{
		.description = "Y_CBCR_H2V2",
		.pixelformat = SDE_PIX_FMT_Y_CBCR_H2V2,
	},
	{
		.description = "Y_CRCB_H2V2",
		.pixelformat = SDE_PIX_FMT_Y_CRCB_H2V2,
	},
	{
		.description = "Y_CBCR_H1V2",
		.pixelformat = SDE_PIX_FMT_Y_CBCR_H1V2,
	},
	{
		.description = "Y_CRCB_H1V2",
		.pixelformat = SDE_PIX_FMT_Y_CRCB_H1V2,
	},
	{
		.description = "Y_CBCR_H2V1",
		.pixelformat = SDE_PIX_FMT_Y_CBCR_H2V1,
	},
	{
		.description = "Y_CRCB_H2V1",
		.pixelformat = SDE_PIX_FMT_Y_CRCB_H2V1,
	},
	{
		.description = "YCBYCR_H2V1",
		.pixelformat = SDE_PIX_FMT_YCBYCR_H2V1,
	},
	{
		.description = "SDE/Y_CBCR_H2V2_VENUS",
		.pixelformat = SDE_PIX_FMT_Y_CBCR_H2V2_VENUS,
	},
	{
		.description = "SDE/Y_CRCB_H2V2_VENUS",
		.pixelformat = SDE_PIX_FMT_Y_CRCB_H2V2_VENUS,
	},
	{
		.description = "SDE/RGBA_8888_UBWC",
		.pixelformat = SDE_PIX_FMT_RGBA_8888_UBWC,
	},
	{
		.description = "SDE/RGBX_8888_UBWC",
		.pixelformat = SDE_PIX_FMT_RGBX_8888_UBWC,
	},
	{
		.description = "SDE/RGB_565_UBWC",
		.pixelformat = SDE_PIX_FMT_RGB_565_UBWC,
	},
	{
		.description = "SDE/Y_CBCR_H2V2_UBWC",
		.pixelformat = SDE_PIX_FMT_Y_CBCR_H2V2_UBWC,
	},
	{
		.description = "SDE/RGBA_1010102",
		.pixelformat = SDE_PIX_FMT_RGBA_1010102,
	},
	{
		.description = "SDE/RGBX_1010102",
		.pixelformat = SDE_PIX_FMT_RGBX_1010102,
	},
	{
		.description = "SDE/ARGB_2101010",
		.pixelformat = SDE_PIX_FMT_ARGB_2101010,
	},
	{
		.description = "SDE/XRGB_2101010",
		.pixelformat = SDE_PIX_FMT_XRGB_2101010,
	},
	{
		.description = "SDE/BGRA_1010102",
		.pixelformat = SDE_PIX_FMT_BGRA_1010102,
	},
	{
		.description = "SDE/BGRX_1010102",
		.pixelformat = SDE_PIX_FMT_BGRX_1010102,
	},
	{
		.description = "SDE/ABGR_2101010",
		.pixelformat = SDE_PIX_FMT_ABGR_2101010,
	},
	{
		.description = "SDE/XBGR_2101010",
		.pixelformat = SDE_PIX_FMT_XBGR_2101010,
	},
	{
		.description = "SDE/RGBA_1010102_UBWC",
		.pixelformat = SDE_PIX_FMT_RGBA_1010102_UBWC,
	},
	{
		.description = "SDE/RGBX_1010102_UBWC",
		.pixelformat = SDE_PIX_FMT_RGBX_1010102_UBWC,
	},
	{
		.description = "SDE/Y_CBCR_H2V2_P010",
		.pixelformat = SDE_PIX_FMT_Y_CBCR_H2V2_P010,
	},
	{
		.description = "SDE/Y_CBCR_H2V2_TP10",
		.pixelformat = SDE_PIX_FMT_Y_CBCR_H2V2_TP10,
	},
	{
		.description = "SDE/Y_CBCR_H2V2_TP10_UBWC",
		.pixelformat = SDE_PIX_FMT_Y_CBCR_H2V2_TP10_UBWC,
	},
};

static void sde_rotator_submit_handler(struct work_struct *work);
static void sde_rotator_retire_handler(struct work_struct *work);
@@ -308,26 +70,6 @@ static inline struct sde_rotator_ctx *sde_rotator_ctx_from_fh(
	return container_of(fh, struct sde_rotator_ctx, fh);
}

/*
 * sde_rotator_get_format_idx - Get rotator format lookup index.
 * @ctx: Pointer to rotator ctx.
 * @f: v4l2 format.
 */
static int sde_rotator_get_format_idx(struct sde_rotator_ctx *ctx,
	struct v4l2_format *f)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(fmtdesc); i++)
		if (fmtdesc[i].pixelformat == f->fmt.pix.pixelformat)
			break;

	if (i == ARRAY_SIZE(fmtdesc))
		return -EINVAL;

	return i;
}

/*
 * sde_rotator_get_flags_from_ctx - Get low-level command flag
 * @ctx: Pointer to rotator context.
@@ -1302,12 +1044,21 @@ static int sde_rotator_querycap(struct file *file,
static int sde_rotator_enum_fmt_vid_cap(struct file *file,
	void *fh, struct v4l2_fmtdesc *f)
{
	if (f->index >= ARRAY_SIZE(fmtdesc))
	struct sde_rotator_ctx *ctx = sde_rotator_ctx_from_fh(fh);
	struct sde_rotator_device *rot_dev = ctx->rot_dev;
	struct sde_mdp_format_params *fmt;
	u32 pixfmt;

	pixfmt = sde_rotator_get_pixfmt(rot_dev->mgr, f->index, false);
	if (!pixfmt)
		return -EINVAL;

	fmt = sde_get_format_params(pixfmt);
	if (!fmt)
		return -EINVAL;

	f->pixelformat = fmtdesc[f->index].pixelformat;
	strlcpy(f->description, fmtdesc[f->index].description,
		sizeof(f->description));
	f->pixelformat = pixfmt;
	strlcpy(f->description, fmt->description, sizeof(f->description));

	return 0;
}
@@ -1321,12 +1072,21 @@ static int sde_rotator_enum_fmt_vid_cap(struct file *file,
static int sde_rotator_enum_fmt_vid_out(struct file *file,
	void *fh, struct v4l2_fmtdesc *f)
{
	if (f->index >= ARRAY_SIZE(fmtdesc))
	struct sde_rotator_ctx *ctx = sde_rotator_ctx_from_fh(fh);
	struct sde_rotator_device *rot_dev = ctx->rot_dev;
	struct sde_mdp_format_params *fmt;
	u32 pixfmt;

	pixfmt = sde_rotator_get_pixfmt(rot_dev->mgr, f->index, true);
	if (!pixfmt)
		return -EINVAL;

	fmt = sde_get_format_params(pixfmt);
	if (!fmt)
		return -EINVAL;

	f->pixelformat = fmtdesc[f->index].pixelformat;
	strlcpy(f->description, fmtdesc[f->index].description,
		sizeof(f->description));
	f->pixelformat = pixfmt;
	strlcpy(f->description, fmt->description, sizeof(f->description));

	return 0;
}
@@ -1375,13 +1135,8 @@ static int sde_rotator_try_fmt_vid_cap(struct file *file,
	struct sde_rotator_ctx *ctx = sde_rotator_ctx_from_fh(fh);
	struct sde_rotator_device *rot_dev = ctx->rot_dev;
	struct sde_rotation_config config;
	int fmt_idx;
	int ret;

	fmt_idx = sde_rotator_get_format_idx(ctx, f);
	if (fmt_idx < 0)
		return -EINVAL;

	sde_rot_mgr_lock(rot_dev->mgr);
	sde_rotator_get_config_from_ctx(ctx, &config);
	config.output.format = f->fmt.pix.pixelformat;
@@ -1419,13 +1174,8 @@ static int sde_rotator_try_fmt_vid_out(struct file *file,
	struct sde_rotator_ctx *ctx = sde_rotator_ctx_from_fh(fh);
	struct sde_rotator_device *rot_dev = ctx->rot_dev;
	struct sde_rotation_config config;
	int fmt_idx;
	int ret;

	fmt_idx = sde_rotator_get_format_idx(ctx, f);
	if (fmt_idx < 0)
		return -EINVAL;

	sde_rot_mgr_lock(rot_dev->mgr);
	sde_rotator_get_config_from_ctx(ctx, &config);
	config.input.format = f->fmt.pix.pixelformat;
+141 −137

File changed.

Preview size limit exceeded, changes collapsed.

+1 −10
Original line number Diff line number Diff line
@@ -17,19 +17,11 @@
#include <linux/types.h>
#include <media/msm_sde_rotator.h>

/* internal formats */
#define SDE_PIX_FMT_Y_CBCR_H2V2_TP10	v4l2_fourcc('T', 'P', '1', '0')

#define SDE_ROT_MAX_PLANES		4

#define UBWC_META_MACRO_W_H		16
#define UBWC_META_BLOCK_SIZE		256

#define INVALID_WB_FORMAT		0
#define VALID_ROT_WB_FORMAT		BIT(0)
#define VALID_MDP_WB_INTF_FORMAT	BIT(1)
#define VALID_ROT_R3_WB_FORMAT		BIT(2)

/*
 * Value of enum chosen to fit the number of bits
 * expected by the HW programming.
@@ -79,6 +71,7 @@ enum sde_mdp_sspp_chroma_samp_type {

struct sde_mdp_format_params {
	u32 format;
	const char *description;
	u32 flag;
	u8 is_yuv;
	u8 is_ubwc;
@@ -111,8 +104,6 @@ struct sde_mdp_format_params *sde_get_format_params(u32 format);

int sde_rot_get_ubwc_micro_dim(u32 format, u16 *w, u16 *h);

bool sde_mdp_is_wb_format(struct sde_mdp_format_params *fmt);

static inline bool sde_mdp_is_tilea4x_format(struct sde_mdp_format_params *fmt)
{
	return fmt && (fmt->frame_format == SDE_MDP_FMT_TILE_A4X);
Loading