drivers/media/platform/microchip/microchip-isc-scaler.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/microchip/microchip-isc-scaler.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/microchip/microchip-isc-scaler.c- Extension
.c- Size
- 7776 bytes
- Lines
- 272
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
media/media-device.hmedia/media-entity.hmedia/v4l2-device.hmedia/v4l2-subdev.hmicrochip-isc-regs.hmicrochip-isc.h
Detected Declarations
function Controllerfunction isc_scaler_get_fmtfunction isc_scaler_set_fmtfunction isc_scaler_enum_mbus_codefunction modulefunction isc_scaler_g_selfunction isc_scaler_init_statefunction isc_scaler_initfunction isc_scaler_linkexport isc_scaler_initexport isc_scaler_link
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Microchip Image Sensor Controller (ISC) Scaler entity support
*
* Copyright (C) 2022 Microchip Technology, Inc.
*
* Author: Eugen Hristev <eugen.hristev@microchip.com>
*
*/
#include <media/media-device.h>
#include <media/media-entity.h>
#include <media/v4l2-device.h>
#include <media/v4l2-subdev.h>
#include "microchip-isc-regs.h"
#include "microchip-isc.h"
static void isc_scaler_prepare_fmt(struct v4l2_mbus_framefmt *framefmt)
{
framefmt->colorspace = V4L2_COLORSPACE_SRGB;
framefmt->field = V4L2_FIELD_NONE;
framefmt->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
framefmt->quantization = V4L2_QUANTIZATION_DEFAULT;
framefmt->xfer_func = V4L2_XFER_FUNC_DEFAULT;
};
static int isc_scaler_get_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *format)
{
struct isc_device *isc = container_of(sd, struct isc_device, scaler_sd);
struct v4l2_mbus_framefmt *v4l2_try_fmt;
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
v4l2_try_fmt = v4l2_subdev_state_get_format(sd_state,
format->pad);
format->format = *v4l2_try_fmt;
return 0;
}
format->format = isc->scaler_format[format->pad];
return 0;
}
static int isc_scaler_set_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *req_fmt)
{
struct isc_device *isc = container_of(sd, struct isc_device, scaler_sd);
struct v4l2_mbus_framefmt *v4l2_try_fmt;
struct isc_format *fmt;
unsigned int i;
/* Source format is fixed, we cannot change it */
if (req_fmt->pad == ISC_SCALER_PAD_SOURCE) {
req_fmt->format = isc->scaler_format[ISC_SCALER_PAD_SOURCE];
return 0;
}
/* There is no limit on the frame size on the sink pad */
v4l_bound_align_image(&req_fmt->format.width, 16, UINT_MAX, 0,
&req_fmt->format.height, 16, UINT_MAX, 0, 0);
isc_scaler_prepare_fmt(&req_fmt->format);
fmt = isc_find_format_by_code(isc, req_fmt->format.code, &i);
if (!fmt)
fmt = &isc->formats_list[0];
req_fmt->format.code = fmt->mbus_code;
if (req_fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
v4l2_try_fmt = v4l2_subdev_state_get_format(sd_state,
req_fmt->pad);
*v4l2_try_fmt = req_fmt->format;
/* Trying on the sink pad makes the source pad change too */
v4l2_try_fmt = v4l2_subdev_state_get_format(sd_state,
ISC_SCALER_PAD_SOURCE);
*v4l2_try_fmt = req_fmt->format;
v4l_bound_align_image(&v4l2_try_fmt->width,
16, isc->max_width, 0,
&v4l2_try_fmt->height,
16, isc->max_height, 0, 0);
/* if we are just trying, we are done */
return 0;
Annotation
- Immediate include surface: `media/media-device.h`, `media/media-entity.h`, `media/v4l2-device.h`, `media/v4l2-subdev.h`, `microchip-isc-regs.h`, `microchip-isc.h`.
- Detected declarations: `function Controller`, `function isc_scaler_get_fmt`, `function isc_scaler_set_fmt`, `function isc_scaler_enum_mbus_code`, `function module`, `function isc_scaler_g_sel`, `function isc_scaler_init_state`, `function isc_scaler_init`, `function isc_scaler_link`, `export isc_scaler_init`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.