Commit 9a29f5fc authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab
Browse files

media: atomisp: Add ia_css_frame_get_info() helper



Several places rely on the [frame_]info member being the first member of
struct ia_css_frame, so that &frame->info will yield NULL when frame is
NULL (some places already explicitly check for a NULL frame pointer but
not nearly all).

For videobuf2 support the vb2_v4l2_buffer struct needs to be embedded
in the frame struct and it needs to be the first member. Breaking the
assumption that &frame->info will yield NULL when frame is NULL.

Add a ia_css_frame_get_info() helper to return either the ia_css_frame_info
struct embedded in the frame, or NULL when the frame pointer is NULL and
use this in places where a ia_css_frame_info ptr or NULL is expected.

To make sure that we catch all uses of the info field this patch also
renames the info field to frame_info.

This is a preparation patch for converting the driver to videobuf2.

Reviewed-by: default avatarAndy Shevchenko <andy@kernel.org>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent ce8e2632
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -992,7 +992,7 @@ static int remove_pad_from_frame(struct atomisp_device *isp,
		if (ret < 0)
			goto remove_pad_error;

		load  += in_frame->info.padded_width;
		load  += in_frame->frame_info.padded_width;
		store += width;
	}

+8 −2
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ enum ia_css_frame_flash_state {
 *  This is the main structure used for all input and output images.
 */
struct ia_css_frame {
	struct ia_css_frame_info info; /** info struct describing the frame */
	struct ia_css_frame_info frame_info; /** info struct describing the frame */
	ia_css_ptr   data;	       /** pointer to start of image data */
	unsigned int data_bytes;       /** size of image data in bytes */
	/* LA: move this to ia_css_buffer */
@@ -184,7 +184,7 @@ struct ia_css_frame {
};

#define DEFAULT_FRAME { \
	.info			= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	.frame_info		= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	.dynamic_queue_id	= SH_CSS_INVALID_QUEUE_ID, \
	.buf_type		= IA_CSS_BUFFER_TYPE_INVALID, \
	.flash_state		= IA_CSS_FRAME_FLASH_STATE_NONE, \
@@ -320,4 +320,10 @@ ia_css_frame_map(struct ia_css_frame **frame,
void
ia_css_frame_unmap(struct ia_css_frame *frame);

static inline const struct ia_css_frame_info *
ia_css_frame_get_info(const struct ia_css_frame *frame)
{
	return frame ? &frame->frame_info : NULL;
}

#endif /* __IA_CSS_FRAME_PUBLIC_H */
+4 −6
Original line number Diff line number Diff line
@@ -28,9 +28,7 @@ int ia_css_bayer_io_config(const struct ia_css_binary *binary,
	const struct ia_css_frame *in_frame = args->in_frame;
	const struct ia_css_frame **out_frames = (const struct ia_css_frame **)
		&args->out_frame;
	const struct ia_css_frame_info *in_frame_info = (in_frame) ? &in_frame->info :
		&binary->in_frame_info;

	const struct ia_css_frame_info *in_frame_info = ia_css_frame_get_info(in_frame);
	const unsigned int ddr_bits_per_element = sizeof(short) * 8;
	const unsigned int ddr_elems_per_word = ceil_div(HIVE_ISP_DDR_WORD_BITS,
						ddr_bits_per_element);
@@ -80,12 +78,12 @@ int ia_css_bayer_io_config(const struct ia_css_binary *binary,
				    "ia_css_bayer_io_config() put part enter:\n");
#endif

		ret = ia_css_dma_configure_from_info(&config, &out_frames[0]->info);
		ret = ia_css_dma_configure_from_info(&config, &out_frames[0]->frame_info);
		if (ret)
			return ret;
		to->base_address = out_frames[0]->data;
		to->width = out_frames[0]->info.res.width;
		to->height = out_frames[0]->info.res.height;
		to->width = out_frames[0]->frame_info.res.width;
		to->height = out_frames[0]->frame_info.res.height;
		to->stride = config.stride;
		to->ddr_elems_per_word = ddr_elems_per_word;

+4 −6
Original line number Diff line number Diff line
@@ -28,9 +28,7 @@ int ia_css_yuv444_io_config(const struct ia_css_binary *binary,
	const struct ia_css_frame *in_frame = args->in_frame;
	const struct ia_css_frame **out_frames = (const struct ia_css_frame **)
		&args->out_frame;
	const struct ia_css_frame_info *in_frame_info = (in_frame) ? &in_frame->info :
		&binary->in_frame_info;

	const struct ia_css_frame_info *in_frame_info = ia_css_frame_get_info(in_frame);
	const unsigned int ddr_bits_per_element = sizeof(short) * 8;
	const unsigned int ddr_elems_per_word = ceil_div(HIVE_ISP_DDR_WORD_BITS,
						ddr_bits_per_element);
@@ -81,13 +79,13 @@ int ia_css_yuv444_io_config(const struct ia_css_binary *binary,
				    "ia_css_yuv444_io_config() put part enter:\n");
#endif

		ret = ia_css_dma_configure_from_info(&config, &out_frames[0]->info);
		ret = ia_css_dma_configure_from_info(&config, &out_frames[0]->frame_info);
		if (ret)
			return ret;

		to->base_address = out_frames[0]->data;
		to->width = out_frames[0]->info.res.width;
		to->height = out_frames[0]->info.res.height;
		to->width = out_frames[0]->frame_info.res.width;
		to->height = out_frames[0]->frame_info.res.height;
		to->stride = config.stride;
		to->ddr_elems_per_word = ddr_elems_per_word;

+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ int ia_css_ref_config(struct sh_css_isp_ref_isp_config *to,
	int ret;

	if (from->ref_frames[0]) {
		ret = ia_css_dma_configure_from_info(&to->port_b, &from->ref_frames[0]->info);
		ret = ia_css_dma_configure_from_info(&to->port_b, &from->ref_frames[0]->frame_info);
		if (ret)
			return ret;
		to->width_a_over_b = elems_a / to->port_b.elems;
Loading