drivers/media/rc/img-ir/img-ir-rc6.c
Source file repositories/reference/linux-study-clean/drivers/media/rc/img-ir/img-ir-rc6.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/rc/img-ir/img-ir-rc6.c- Extension
.c- Size
- 2482 bytes
- Lines
- 114
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
img-ir-hw.h
Detected Declarations
function img_ir_rc6_scancodefunction img_ir_rc6_filter
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* ImgTec IR Decoder setup for Philips RC-6 protocol.
*
* Copyright 2012-2014 Imagination Technologies Ltd.
*/
#include "img-ir-hw.h"
/* Convert RC6 data to a scancode */
static int img_ir_rc6_scancode(int len, u64 raw, u64 enabled_protocols,
struct img_ir_scancode_req *request)
{
unsigned int addr, cmd, mode, trl1, trl2;
/*
* Due to a side effect of the decoder handling the double length
* Trailer bit, the header information is a bit scrambled, and the
* raw data is shifted incorrectly.
* This workaround effectively recovers the header bits.
*
* The Header field should look like this:
*
* StartBit ModeBit2 ModeBit1 ModeBit0 TrailerBit
*
* But what we get is:
*
* ModeBit2 ModeBit1 ModeBit0 TrailerBit1 TrailerBit2
*
* The start bit is not important to recover the scancode.
*/
raw >>= 27;
trl1 = (raw >> 17) & 0x01;
trl2 = (raw >> 16) & 0x01;
mode = (raw >> 18) & 0x07;
addr = (raw >> 8) & 0xff;
cmd = raw & 0xff;
/*
* Due to the above explained irregularity the trailer bits cannot
* have the same value.
*/
if (trl1 == trl2)
return -EINVAL;
/* Only mode 0 supported for now */
if (mode)
return -EINVAL;
request->protocol = RC_PROTO_RC6_0;
request->scancode = addr << 8 | cmd;
request->toggle = trl2;
return IMG_IR_SCANCODE;
}
/* Convert RC6 scancode to RC6 data filter */
static int img_ir_rc6_filter(const struct rc_scancode_filter *in,
struct img_ir_filter *out, u64 protocols)
{
/* Not supported by the hw. */
return -EINVAL;
}
/*
* RC-6 decoder
* see http://www.sbprojects.com/knowledge/ir/rc6.php
*/
struct img_ir_decoder img_ir_rc6 = {
.type = RC_PROTO_BIT_RC6_0,
.control = {
.bitorien = 1,
.code_type = IMG_IR_CODETYPE_BIPHASE,
.decoden = 1,
.decodinpol = 1,
},
/* main timings */
.tolerance = 20,
/*
* Due to a quirk in the img-ir decoder, default header values do
* not work, the values described below were extracted from
* successful RTL test cases.
*/
.timings = {
/* leader symbol */
.ldr = {
.pulse = { 650 },
.space = { 660 },
Annotation
- Immediate include surface: `img-ir-hw.h`.
- Detected declarations: `function img_ir_rc6_scancode`, `function img_ir_rc6_filter`.
- 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.