Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: video: imager: move the boilerplate in a library #88003

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

josuah
Copy link
Collaborator

@josuah josuah commented Apr 1, 2025

Split out of:

Dependencies:

Downstream:

Most image sensor drivers are the same. What changes from driver to driver is mostly the content of tables of registers.
This offers a default implementation that will cover everything except init(), set_stream() and set/get_ctrl().

The emulated image sensor is converted to use this implementation as an example, while also making this shared code tested on CI.

@josuah
Copy link
Collaborator Author

josuah commented Apr 2, 2025

Force-push:

josuah added 7 commits April 8, 2025 15:04
Add a library for the Camera Common Interface, part of the MIPI CSI
protocol standard defining methods to configure a camera device over I2C,
such as which size for the register address/data.

Signed-off-by: Josuah Demangeon <me@josuah.net>
Reduce the amount of code in the GC2145 driver by switching to the CCI
helpers in video_common.c. The batch I2C write functions are not used
to avoid increasing the size of the ROM, as struct video_reg is 8 bytes
while the ad-hoc struct gc2145_reg is 2 bytes.

Signed-off-by: Josuah Demangeon <me@josuah.net>
Replace the ad-hoc register emulation by the dedicated I2C emulator,
making it usable with the same APIs as every other image sensors.

Signed-off-by: Josuah Demangeon <me@josuah.net>
Use the newly introduced CCI library instead of local implementation of
I2C read/write commands.

Signed-off-by: Josuah Demangeon <me@josuah.net>
Fix bug introduced in 46a262f where the
fie.index field was expected to be incremented by the driver, while it
is the responsibility of the caller to increment it.

Signed-off-by: Josuah Demangeon <me@josuah.net>
Imagers, also known as image sensors, have drivers that look very similar.
Add common implementation that fits most image sensors, which can be
bypassed wherever this does not make the implementation simpler.

Signed-off-by: Josuah Demangeon <me@josuah.net>
Make the emulated imager use the shared implementation of all imagers,
making shared implementation of the image sensor drivers be tested by CI.

Signed-off-by: Josuah Demangeon <me@josuah.net>
@josuah josuah force-pushed the pr-video-imager branch from e52c4c5 to 47d1bb5 Compare April 8, 2025 14:45
@josuah
Copy link
Collaborator Author

josuah commented Apr 10, 2025

From Linux docs:

Register list based drivers generally [...] are limited to a number of preset configurations that combine a number of different parameters [...]. How a driver picks such configuration is based on the format set [...]. Most sensor drivers are implemented this way.
-- https://www.kernel.org/doc/html/latest/userspace-api/media/drivers/camera-sensor.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Video Video subsystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant