drivers/media/test-drivers/vimc/vimc-scaler.c
Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/vimc/vimc-scaler.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/test-drivers/vimc/vimc-scaler.c- Extension
.c- Size
- 11197 bytes
- Lines
- 423
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/moduleparam.hlinux/string.hlinux/vmalloc.hlinux/v4l2-mediabus.hmedia/v4l2-rect.hmedia/v4l2-subdev.hvimc-common.h
Detected Declarations
struct vimc_scaler_deviceenum vimc_scaler_padfunction vimc_scaler_get_crop_bound_sinkfunction vimc_scaler_init_statefunction vimc_scaler_enum_mbus_codefunction vimc_scaler_enum_frame_sizefunction vimc_scaler_set_fmtfunction vimc_scaler_get_selectionfunction vimc_scaler_adjust_sink_cropfunction vimc_scaler_set_selectionfunction vimc_scaler_s_streamfunction vimc_scaler_fill_src_framefunction vimc_scaler_release
Annotated Snippet
struct vimc_scaler_device {
struct vimc_ent_device ved;
struct v4l2_subdev sd;
struct media_pad pads[2];
u8 *src_frame;
/*
* Virtual "hardware" configuration, filled when the stream starts or
* when controls are set.
*/
struct {
struct v4l2_mbus_framefmt sink_fmt;
struct v4l2_mbus_framefmt src_fmt;
struct v4l2_rect sink_crop;
unsigned int bpp;
} hw;
};
static const struct v4l2_mbus_framefmt fmt_default = {
.width = VIMC_SCALER_FMT_WIDTH_DEFAULT,
.height = VIMC_SCALER_FMT_HEIGHT_DEFAULT,
.code = MEDIA_BUS_FMT_RGB888_1X24,
.field = V4L2_FIELD_NONE,
.colorspace = V4L2_COLORSPACE_SRGB,
};
static const struct v4l2_rect crop_rect_default = {
.width = VIMC_SCALER_FMT_WIDTH_DEFAULT,
.height = VIMC_SCALER_FMT_HEIGHT_DEFAULT,
.top = 0,
.left = 0,
};
static const struct v4l2_rect crop_rect_min = {
.width = VIMC_FRAME_MIN_WIDTH,
.height = VIMC_FRAME_MIN_HEIGHT,
.top = 0,
.left = 0,
};
static struct v4l2_rect
vimc_scaler_get_crop_bound_sink(const struct v4l2_mbus_framefmt *sink_fmt)
{
/* Get the crop bounds to clamp the crop rectangle correctly */
struct v4l2_rect r = {
.left = 0,
.top = 0,
.width = sink_fmt->width,
.height = sink_fmt->height,
};
return r;
}
static int vimc_scaler_init_state(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state)
{
struct v4l2_mbus_framefmt *mf;
struct v4l2_rect *r;
unsigned int i;
for (i = 0; i < sd->entity.num_pads; i++) {
mf = v4l2_subdev_state_get_format(sd_state, i);
*mf = fmt_default;
}
r = v4l2_subdev_state_get_crop(sd_state, VIMC_SCALER_SINK);
*r = crop_rect_default;
return 0;
}
static int vimc_scaler_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
{
u32 mbus_code = vimc_mbus_code_by_index(code->index);
const struct vimc_pix_map *vpix;
if (!mbus_code)
return -EINVAL;
vpix = vimc_pix_map_by_code(mbus_code);
/* We don't support bayer format */
if (!vpix || vpix->bayer)
return -EINVAL;
code->code = mbus_code;
Annotation
- Immediate include surface: `linux/moduleparam.h`, `linux/string.h`, `linux/vmalloc.h`, `linux/v4l2-mediabus.h`, `media/v4l2-rect.h`, `media/v4l2-subdev.h`, `vimc-common.h`.
- Detected declarations: `struct vimc_scaler_device`, `enum vimc_scaler_pad`, `function vimc_scaler_get_crop_bound_sink`, `function vimc_scaler_init_state`, `function vimc_scaler_enum_mbus_code`, `function vimc_scaler_enum_frame_size`, `function vimc_scaler_set_fmt`, `function vimc_scaler_get_selection`, `function vimc_scaler_adjust_sink_crop`, `function vimc_scaler_set_selection`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.