drivers/media/usb/gspca/jl2005bcd.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/jl2005bcd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/jl2005bcd.c- Extension
.c- Size
- 13200 bytes
- Lines
- 525
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/workqueue.hlinux/slab.hgspca.h
Detected Declarations
struct sdfunction jl2005c_write2function jl2005c_read1function jl2005c_read_regfunction jl2005c_start_new_framefunction jl2005c_write_regfunction jl2005c_get_firmware_idfunction jl2005c_stream_start_vga_lgfunction jl2005c_stream_start_vga_smallfunction jl2005c_stream_start_cif_lgfunction jl2005c_stream_start_cif_smallfunction jl2005c_stopfunction jl2005c_dostreamfunction sd_configfunction sd_initfunction sd_startfunction sd_stop0function sd_probe
Annotated Snippet
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
unsigned char firmware_id[6];
const struct v4l2_pix_format *cap_mode;
/* Driver stuff */
struct work_struct work_struct;
u8 frame_brightness;
int block_size; /* block size of camera */
int vga; /* 1 if vga cam, 0 if cif cam */
};
/* Camera has two resolution settings. What they are depends on model. */
static const struct v4l2_pix_format cif_mode[] = {
{176, 144, V4L2_PIX_FMT_JL2005BCD, V4L2_FIELD_NONE,
.bytesperline = 176,
.sizeimage = 176 * 144,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 0},
{352, 288, V4L2_PIX_FMT_JL2005BCD, V4L2_FIELD_NONE,
.bytesperline = 352,
.sizeimage = 352 * 288,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 0},
};
static const struct v4l2_pix_format vga_mode[] = {
{320, 240, V4L2_PIX_FMT_JL2005BCD, V4L2_FIELD_NONE,
.bytesperline = 320,
.sizeimage = 320 * 240,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 0},
{640, 480, V4L2_PIX_FMT_JL2005BCD, V4L2_FIELD_NONE,
.bytesperline = 640,
.sizeimage = 640 * 480,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 0},
};
/*
* cam uses endpoint 0x03 to send commands, 0x84 for read commands,
* and 0x82 for bulk data transfer.
*/
/* All commands are two bytes only */
static int jl2005c_write2(struct gspca_dev *gspca_dev, unsigned char *command)
{
int retval;
memcpy(gspca_dev->usb_buf, command, 2);
retval = usb_bulk_msg(gspca_dev->dev,
usb_sndbulkpipe(gspca_dev->dev, 3),
gspca_dev->usb_buf, 2, NULL, 500);
if (retval < 0)
pr_err("command write [%02x] error %d\n",
gspca_dev->usb_buf[0], retval);
return retval;
}
/* Response to a command is one byte in usb_buf[0], only if requested. */
static int jl2005c_read1(struct gspca_dev *gspca_dev)
{
int retval;
retval = usb_bulk_msg(gspca_dev->dev,
usb_rcvbulkpipe(gspca_dev->dev, 0x84),
gspca_dev->usb_buf, 1, NULL, 500);
if (retval < 0)
pr_err("read command [0x%02x] error %d\n",
gspca_dev->usb_buf[0], retval);
return retval;
}
/* Response appears in gspca_dev->usb_buf[0] */
static int jl2005c_read_reg(struct gspca_dev *gspca_dev, unsigned char reg)
{
int retval;
static u8 instruction[2] = {0x95, 0x00};
/* put register to read in byte 1 */
instruction[1] = reg;
/* Send the read request */
retval = jl2005c_write2(gspca_dev, instruction);
if (retval < 0)
return retval;
retval = jl2005c_read1(gspca_dev);
return retval;
}
Annotation
- Immediate include surface: `linux/workqueue.h`, `linux/slab.h`, `gspca.h`.
- Detected declarations: `struct sd`, `function jl2005c_write2`, `function jl2005c_read1`, `function jl2005c_read_reg`, `function jl2005c_start_new_frame`, `function jl2005c_write_reg`, `function jl2005c_get_firmware_id`, `function jl2005c_stream_start_vga_lg`, `function jl2005c_stream_start_vga_small`, `function jl2005c_stream_start_cif_lg`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.