drivers/staging/media/atomisp/pci/runtime/frame/src/frame.c

Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/runtime/frame/src/frame.c

File Facts

System
Linux kernel
Corpus path
drivers/staging/media/atomisp/pci/runtime/frame/src/frame.c
Extension
.c
Size
21991 bytes
Lines
741
Domain
Driver Families
Bucket
drivers/staging
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (frames_array[i]) {
			ia_css_frame_free(frames_array[i]);
			frames_array[i] = NULL;
		}
	}
}

int ia_css_frame_allocate_with_buffer_size(struct ia_css_frame **frame,
					   const unsigned int buffer_size_bytes)
{
	/* AM: Body copied from frame_allocate_with_data(). */
	int err;
	struct ia_css_frame *me = frame_create(0, 0,
					       IA_CSS_FRAME_FORMAT_NUM,/* Not valid format yet */
					       0, 0, false);

	if (!me)
		return -ENOMEM;

	/* Get the data size */
	me->data_bytes = buffer_size_bytes;

	err = frame_allocate_buffer_data(me);

	if (err) {
		kvfree(me);
		me = NULL;
	}

	*frame = me;

	return err;
}

bool ia_css_frame_info_is_same_resolution(
    const struct ia_css_frame_info *info_a,
    const struct ia_css_frame_info *info_b)
{
	if (!info_a || !info_b)
		return false;
	return (info_a->res.width == info_b->res.width) &&
	       (info_a->res.height == info_b->res.height);
}

bool ia_css_frame_is_same_type(const struct ia_css_frame *frame_a,
			       const struct ia_css_frame *frame_b)
{
	bool is_equal = false;
	const struct ia_css_frame_info *info_a = &frame_a->frame_info;
	const struct ia_css_frame_info *info_b = &frame_b->frame_info;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
			    "ia_css_frame_is_same_type() enter:\n");

	if (!info_a || !info_b)
		return false;
	if (info_a->format != info_b->format)
		return false;
	if (info_a->padded_width != info_b->padded_width)
		return false;
	is_equal = ia_css_frame_info_is_same_resolution(info_a, info_b);

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
			    "ia_css_frame_is_same_type() leave:\n");

	return is_equal;
}

int ia_css_dma_configure_from_info(struct dma_port_config *config,
				   const struct ia_css_frame_info *info)
{
	unsigned int is_raw_packed = info->format == IA_CSS_FRAME_FORMAT_RAW_PACKED;
	unsigned int bits_per_pixel = is_raw_packed ? info->raw_bit_depth :
				      ia_css_elems_bytes_from_info(info) * 8;
	unsigned int pix_per_ddrword = HIVE_ISP_DDR_WORD_BITS / bits_per_pixel;
	unsigned int words_per_line = CEIL_DIV(info->padded_width, pix_per_ddrword);
	unsigned int elems_b = pix_per_ddrword;

	config->stride = HIVE_ISP_DDR_WORD_BYTES * words_per_line;
	config->elems  = (uint8_t)elems_b;
	config->width  = (uint16_t)info->res.width;
	config->crop   = 0;

	if (config->width > info->padded_width) {
		dev_err(atomisp_dev, "internal error: padded_width is too small!\n");
		return -EINVAL;
	}

	return 0;
}

Annotation

Implementation Notes