Commit 86aed3f5 authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Mauro Carvalho Chehab
Browse files

media: mtk-vcodec: avoid unneeded pointer-to-long conversions



The interface used to communicate with the firmware casts pointers
into unsigned longs and back again in order to store private
references, all of this for pointers that remain purely in the kernel.
Replace these unsigned longs with void pointers to make the code a bit
sturdier and easier to follow.

Also simplify some interfaces by removing arguments that could be
infered from others.

Signed-off-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: fix checkpatch alignment warning]
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent d13b3cdc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -273,7 +273,7 @@ struct mtk_vcodec_ctx {

	const struct vdec_common_if *dec_if;
	const struct venc_common_if *enc_if;
	unsigned long drv_handle;
	void *drv_handle;

	struct vdec_pic_info picinfo;
	int dpb_size;
+6 −6
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ static void get_dpb_size(struct vdec_h264_inst *inst, unsigned int *dpb_sz)
	mtk_vcodec_debug(inst, "sz=%d", *dpb_sz);
}

static int vdec_h264_init(struct mtk_vcodec_ctx *ctx, unsigned long *h_vdec)
static int vdec_h264_init(struct mtk_vcodec_ctx *ctx)
{
	struct vdec_h264_inst *inst = NULL;
	int err;
@@ -295,7 +295,7 @@ static int vdec_h264_init(struct mtk_vcodec_ctx *ctx, unsigned long *h_vdec)

	mtk_vcodec_debug(inst, "H264 Instance >> %p", inst);

	*h_vdec = (unsigned long)inst;
	ctx->drv_handle = inst;
	return 0;

error_deinit:
@@ -306,7 +306,7 @@ error_free_inst:
	return err;
}

static void vdec_h264_deinit(unsigned long h_vdec)
static void vdec_h264_deinit(void *h_vdec)
{
	struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec;

@@ -331,7 +331,7 @@ static int find_start_code(unsigned char *data, unsigned int data_sz)
	return -1;
}

static int vdec_h264_decode(unsigned long h_vdec, struct mtk_vcodec_mem *bs,
static int vdec_h264_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
			    struct vdec_fb *fb, bool *res_chg)
{
	struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec;
@@ -451,8 +451,8 @@ static void vdec_h264_get_fb(struct vdec_h264_inst *inst,
	list->count--;
}

static int vdec_h264_get_param(unsigned long h_vdec,
			       enum vdec_get_param_type type, void *out)
static int vdec_h264_get_param(void *h_vdec, enum vdec_get_param_type type,
			       void *out)
{
	struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec;

+6 −6
Original line number Diff line number Diff line
@@ -388,7 +388,7 @@ static void free_working_buf(struct vdec_vp8_inst *inst)
	inst->vsi->dec.working_buf_dma = 0;
}

static int vdec_vp8_init(struct mtk_vcodec_ctx *ctx, unsigned long *h_vdec)
static int vdec_vp8_init(struct mtk_vcodec_ctx *ctx)
{
	struct vdec_vp8_inst *inst;
	int err;
@@ -419,7 +419,7 @@ static int vdec_vp8_init(struct mtk_vcodec_ctx *ctx, unsigned long *h_vdec)
	get_hw_reg_base(inst);
	mtk_vcodec_debug(inst, "VP8 Instance >> %p", inst);

	*h_vdec = (unsigned long)inst;
	ctx->drv_handle = inst;
	return 0;

error_deinit:
@@ -429,7 +429,7 @@ error_free_inst:
	return err;
}

static int vdec_vp8_decode(unsigned long h_vdec, struct mtk_vcodec_mem *bs,
static int vdec_vp8_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
			   struct vdec_fb *fb, bool *res_chg)
{
	struct vdec_vp8_inst *inst = (struct vdec_vp8_inst *)h_vdec;
@@ -565,8 +565,8 @@ static void get_crop_info(struct vdec_vp8_inst *inst, struct v4l2_rect *cr)
			 cr->left, cr->top, cr->width, cr->height);
}

static int vdec_vp8_get_param(unsigned long h_vdec,
			      enum vdec_get_param_type type, void *out)
static int vdec_vp8_get_param(void *h_vdec, enum vdec_get_param_type type,
			      void *out)
{
	struct vdec_vp8_inst *inst = (struct vdec_vp8_inst *)h_vdec;

@@ -599,7 +599,7 @@ static int vdec_vp8_get_param(unsigned long h_vdec,
	return 0;
}

static void vdec_vp8_deinit(unsigned long h_vdec)
static void vdec_vp8_deinit(void *h_vdec)
{
	struct vdec_vp8_inst *inst = (struct vdec_vp8_inst *)h_vdec;

+7 −7
Original line number Diff line number Diff line
@@ -757,7 +757,7 @@ static int validate_vsi_array_indexes(struct vdec_vp9_inst *inst,
	return 0;
}

static void vdec_vp9_deinit(unsigned long h_vdec)
static void vdec_vp9_deinit(void *h_vdec)
{
	struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec;
	struct mtk_vcodec_mem *mem;
@@ -779,7 +779,7 @@ static void vdec_vp9_deinit(unsigned long h_vdec)
	vp9_free_inst(inst);
}

static int vdec_vp9_init(struct mtk_vcodec_ctx *ctx, unsigned long *h_vdec)
static int vdec_vp9_init(struct mtk_vcodec_ctx *ctx)
{
	struct vdec_vp9_inst *inst;

@@ -803,7 +803,7 @@ static int vdec_vp9_init(struct mtk_vcodec_ctx *ctx, unsigned long *h_vdec)
	inst->vsi = (struct vdec_vp9_vsi *)inst->vpu.vsi;
	init_all_fb_lists(inst);

	(*h_vdec) = (unsigned long)inst;
	ctx->drv_handle = inst;
	return 0;

err_deinit_inst:
@@ -812,7 +812,7 @@ err_deinit_inst:
	return -EINVAL;
}

static int vdec_vp9_decode(unsigned long h_vdec, struct mtk_vcodec_mem *bs,
static int vdec_vp9_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
			   struct vdec_fb *fb, bool *res_chg)
{
	int ret = 0;
@@ -969,8 +969,8 @@ static void get_crop_info(struct vdec_vp9_inst *inst, struct v4l2_rect *cr)
			 cr->left, cr->top, cr->width, cr->height);
}

static int vdec_vp9_get_param(unsigned long h_vdec,
		enum vdec_get_param_type type, void *out)
static int vdec_vp9_get_param(void *h_vdec, enum vdec_get_param_type type,
			      void *out)
{
	struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec;
	int ret = 0;
+4 −4
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ struct vdec_common_if {
	 * @ctx     : [in] mtk v4l2 context
	 * @h_vdec  : [out] driver handle
	 */
	int (*init)(struct mtk_vcodec_ctx *ctx, unsigned long *h_vdec);
	int (*init)(struct mtk_vcodec_ctx *ctx);

	/**
	 * (*decode)() - trigger decode
@@ -26,7 +26,7 @@ struct vdec_common_if {
	 * @fb      : [in] frame buffer to store decoded frame
	 * @res_chg : [out] resolution change happen
	 */
	int (*decode)(unsigned long h_vdec, struct mtk_vcodec_mem *bs,
	int (*decode)(void *h_vdec, struct mtk_vcodec_mem *bs,
		      struct vdec_fb *fb, bool *res_chg);

	/**
@@ -35,14 +35,14 @@ struct vdec_common_if {
	 * @type   : [in] input parameter type
	 * @out    : [out] buffer to store query result
	 */
	int (*get_param)(unsigned long h_vdec, enum vdec_get_param_type type,
	int (*get_param)(void *h_vdec, enum vdec_get_param_type type,
			 void *out);

	/**
	 * (*deinit)() - deinitialize driver.
	 * @h_vdec : [in] driver handle to be deinit
	 */
	void (*deinit)(unsigned long h_vdec);
	void (*deinit)(void *h_vdec);
};

#endif
Loading