drivers/media/dvb-frontends/stb0899_algo.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/stb0899_algo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/stb0899_algo.c- Extension
.c- Size
- 50008 bytes
- Lines
- 1523
- 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
linux/bitops.hstb0899_drv.hstb0899_priv.hstb0899_reg.h
Detected Declarations
function Copyrightfunction stb0899_calc_sratefunction stb0899_get_sratefunction stb0899_set_sratefunction stb0899_calc_derot_timefunction stb0899_carr_widthfunction stb0899_first_subrangefunction stb0899_check_tmgfunction stb0899_search_tmgfunction stb0899_check_carrierfunction stb0899_search_carrierfunction stb0899_check_datafunction stb0899_search_datafunction stb0899_check_rangefunction next_sub_rangefunction stb0899_dvbs_algofunction stb0899_dvbs2_config_uwpfunction stb0899_dvbs2_config_csm_autofunction Log2Intfunction stb0899_dvbs2_calc_sratefunction stb0899_dvbs2_calc_devfunction stb0899_dvbs2_set_sratefunction stb0899_dvbs2_set_btr_loopbwfunction stb0899_dvbs2_set_carr_freqfunction stb0899_dvbs2_init_calcfunction stb0899_dvbs2_btr_initfunction stb0899_dvbs2_reacquirefunction stb0899_dvbs2_get_dmd_statusfunction stb0899_dvbs2_get_data_lockfunction stb0899_dvbs2_get_fec_statusfunction stb0899_dvbs2_init_csmfunction stb0899_dvbs2_get_sratefunction stb0899_dvbs2_algo
Annotated Snippet
if ((lock > 48) && (abs(timing) >= 110)) {
internal->status = ANALOGCARRIER;
dprintk(state->verbose, FE_DEBUG, 1, "-->ANALOG Carrier !");
} else {
internal->status = TIMINGOK;
dprintk(state->verbose, FE_DEBUG, 1, "------->TIMING OK !");
}
} else {
internal->status = NOTIMING;
dprintk(state->verbose, FE_DEBUG, 1, "-->NO TIMING !");
}
return internal->status;
}
/*
* stb0899_search_tmg
* perform a fs/2 zig-zag to find timing
*/
static enum stb0899_status stb0899_search_tmg(struct stb0899_state *state)
{
struct stb0899_internal *internal = &state->internal;
struct stb0899_params *params = &state->params;
short int derot_step, derot_freq = 0, derot_limit, next_loop = 3;
int index = 0;
u8 cfr[2];
internal->status = NOTIMING;
/* timing loop computation & symbol rate optimisation */
derot_limit = (internal->sub_range / 2L) / internal->mclk;
derot_step = (params->srate / 2L) / internal->mclk;
while ((stb0899_check_tmg(state) != TIMINGOK) && next_loop) {
index++;
derot_freq += index * internal->direction * derot_step; /* next derot zig zag position */
if (abs(derot_freq) > derot_limit)
next_loop--;
if (next_loop) {
STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(internal->inversion * derot_freq));
STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(internal->inversion * derot_freq));
stb0899_write_regs(state, STB0899_CFRM, cfr, 2); /* derotator frequency */
}
internal->direction = -internal->direction; /* Change zigzag direction */
}
if (internal->status == TIMINGOK) {
stb0899_read_regs(state, STB0899_CFRM, cfr, 2); /* get derotator frequency */
internal->derot_freq = internal->inversion * MAKEWORD16(cfr[0], cfr[1]);
dprintk(state->verbose, FE_DEBUG, 1, "------->TIMING OK ! Derot Freq = %d", internal->derot_freq);
}
return internal->status;
}
/*
* stb0899_check_carrier
* Check for carrier found
*/
static enum stb0899_status stb0899_check_carrier(struct stb0899_state *state)
{
struct stb0899_internal *internal = &state->internal;
u8 reg;
msleep(internal->t_derot); /* wait for derotator ok */
reg = stb0899_read_reg(state, STB0899_CFD);
STB0899_SETFIELD_VAL(CFD_ON, reg, 1);
stb0899_write_reg(state, STB0899_CFD, reg);
reg = stb0899_read_reg(state, STB0899_DSTATUS);
dprintk(state->verbose, FE_DEBUG, 1, "--------------------> STB0899_DSTATUS=[0x%02x]", reg);
if (STB0899_GETFIELD(CARRIER_FOUND, reg)) {
internal->status = CARRIEROK;
dprintk(state->verbose, FE_DEBUG, 1, "-------------> CARRIEROK !");
} else {
internal->status = NOCARRIER;
dprintk(state->verbose, FE_DEBUG, 1, "-------------> NOCARRIER !");
}
return internal->status;
}
/*
* stb0899_search_carrier
* Search for a QPSK carrier with the derotator
*/
static enum stb0899_status stb0899_search_carrier(struct stb0899_state *state)
Annotation
- Immediate include surface: `linux/bitops.h`, `stb0899_drv.h`, `stb0899_priv.h`, `stb0899_reg.h`.
- Detected declarations: `function Copyright`, `function stb0899_calc_srate`, `function stb0899_get_srate`, `function stb0899_set_srate`, `function stb0899_calc_derot_time`, `function stb0899_carr_width`, `function stb0899_first_subrange`, `function stb0899_check_tmg`, `function stb0899_search_tmg`, `function stb0899_check_carrier`.
- 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.