add snr reporting

This commit is contained in:
jmcneill 2011-07-10 00:47:34 +00:00
parent 51b4b9f717
commit fdcf111d68
8 changed files with 242 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: au8522.c,v 1.4 2011/07/09 15:00:43 jmcneill Exp $ */
/* $NetBSD: au8522.c,v 1.5 2011/07/10 00:47:34 jmcneill Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill@invisible.ca>
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: au8522.c,v 1.4 2011/07/09 15:00:43 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: au8522.c,v 1.5 2011/07/10 00:47:34 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -345,9 +345,6 @@ au8522_get_dtv_status(struct au8522 *au)
fe_status_t status = 0;
uint8_t val;
//printf("%s: current_modulation = %d\n", __func__,
// au->current_modulation);
switch (au->current_modulation) {
case VSB_8:
if (au8522_read_1(au, 0x4088, &val))
@ -379,10 +376,49 @@ au8522_get_dtv_status(struct au8522 *au)
status |= FE_HAS_LOCK;
}
//printf("%s: status = 0x%x\n", __func__, status);
return status;
}
uint16_t
au8522_get_snr(struct au8522 *au)
{
const struct au8522_snr_table *snrtab = NULL;
uint16_t snrreg;
uint8_t val;
size_t snrtablen;
unsigned int n;
switch (au->current_modulation) {
case VSB_8:
snrtab = au8522_snr_8vsb;
snrtablen = __arraycount(au8522_snr_8vsb);
snrreg = AU8522_REG_SNR_VSB;
break;
case QAM_64:
snrtab = au8522_snr_qam64;
snrtablen = __arraycount(au8522_snr_qam64);
snrreg = AU8522_REG_SNR_QAM;
break;
case QAM_256:
snrtab = au8522_snr_qam256;
snrtablen = __arraycount(au8522_snr_qam256);
snrreg = AU8522_REG_SNR_QAM;
break;
default:
return 0;
}
if (au8522_read_1(au, snrreg, &val))
return 0;
for (n = 0; n < snrtablen; n++) {
if (val < snrtab[n].val)
return snrtab[n].snr;
}
return 0;
}
MODULE(MODULE_CLASS_DRIVER, au8522, NULL);
static int

View File

@ -1,4 +1,4 @@
/* $NetBSD: au8522mod.h,v 1.1 2011/07/09 15:00:43 jmcneill Exp $ */
/* $NetBSD: au8522mod.h,v 1.2 2011/07/10 00:47:34 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
@ -34,6 +34,11 @@ struct au8522_modulation_table {
uint8_t val;
};
struct au8522_snr_table {
uint16_t val;
uint16_t snr;
};
#include <dev/i2c/au8522mod_8vsb.h>
#include <dev/i2c/au8522mod_qam64.h>
#include <dev/i2c/au8522mod_qam256.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: au8522mod_8vsb.h,v 1.1 2011/07/09 15:00:43 jmcneill Exp $ */
/* $NetBSD: au8522mod_8vsb.h,v 1.2 2011/07/10 00:47:34 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
@ -55,3 +55,36 @@ static const struct au8522_modulation_table au8522_modulation_8vsb[] = {
{ 0x80a4, 0xe8 },
{ 0x8231, 0x13 },
};
static const struct au8522_snr_table au8522_snr_8vsb[] = {
{ 0, 270 },
{ 2, 250 },
{ 3, 240 },
{ 5, 230 },
{ 7, 220 },
{ 9, 210 },
{ 12, 200 },
{ 13, 195 },
{ 15, 190 },
{ 17, 185 },
{ 19, 180 },
{ 21, 175 },
{ 24, 170 },
{ 27, 165 },
{ 31, 160 },
{ 32, 158 },
{ 33, 156 },
{ 36, 152 },
{ 37, 150 },
{ 39, 148 },
{ 40, 146 },
{ 41, 144 },
{ 43, 142 },
{ 44, 140 },
{ 48, 135 },
{ 50, 130 },
{ 43, 142 },
{ 53, 125 },
{ 56, 120 },
{ 256, 115 },
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: au8522mod_qam256.h,v 1.1 2011/07/09 15:00:43 jmcneill Exp $ */
/* $NetBSD: au8522mod_qam256.h,v 1.2 2011/07/10 00:47:34 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
@ -100,3 +100,70 @@ static const struct au8522_modulation_table au8522_modulation_qam256[] = {
{ 0x80a7, 0x40 },
{ 0x8526, 0x01 },
};
static const struct au8522_snr_table au8522_snr_qam256[] = {
{ 16, 0 },
{ 17, 400 },
{ 18, 398 },
{ 19, 396 },
{ 20, 394 },
{ 21, 392 },
{ 22, 390 },
{ 23, 388 },
{ 24, 386 },
{ 25, 384 },
{ 26, 382 },
{ 27, 380 },
{ 28, 379 },
{ 29, 378 },
{ 30, 377 },
{ 31, 376 },
{ 32, 375 },
{ 33, 374 },
{ 34, 373 },
{ 35, 372 },
{ 36, 371 },
{ 37, 370 },
{ 38, 362 },
{ 39, 354 },
{ 40, 346 },
{ 41, 338 },
{ 42, 330 },
{ 43, 328 },
{ 44, 326 },
{ 45, 324 },
{ 46, 322 },
{ 47, 320 },
{ 48, 319 },
{ 49, 318 },
{ 50, 317 },
{ 51, 316 },
{ 52, 315 },
{ 53, 314 },
{ 54, 313 },
{ 55, 312 },
{ 56, 311 },
{ 57, 310 },
{ 58, 308 },
{ 59, 306 },
{ 60, 304 },
{ 61, 302 },
{ 62, 300 },
{ 63, 298 },
{ 65, 295 },
{ 68, 294 },
{ 70, 293 },
{ 73, 292 },
{ 76, 291 },
{ 78, 290 },
{ 79, 289 },
{ 81, 288 },
{ 82, 287 },
{ 83, 286 },
{ 84, 285 },
{ 85, 284 },
{ 86, 283 },
{ 88, 282 },
{ 89, 281 },
{ 256, 280 },
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: au8522mod_qam64.h,v 1.1 2011/07/09 15:00:44 jmcneill Exp $ */
/* $NetBSD: au8522mod_qam64.h,v 1.2 2011/07/10 00:47:34 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
@ -100,3 +100,83 @@ static const struct au8522_modulation_table au8522_modulation_qam64[] = {
{ 0x00a7, 0x40 },
{ 0x0526, 0x01 },
};
static const struct au8522_snr_table au8522_snr_qam64[] = {
{ 15, 0 },
{ 16, 290 },
{ 17, 288 },
{ 18, 286 },
{ 19, 284 },
{ 20, 282 },
{ 21, 281 },
{ 22, 279 },
{ 23, 277 },
{ 24, 275 },
{ 25, 273 },
{ 26, 271 },
{ 27, 269 },
{ 28, 268 },
{ 29, 266 },
{ 30, 264 },
{ 31, 262 },
{ 32, 260 },
{ 33, 259 },
{ 34, 258 },
{ 35, 256 },
{ 36, 255 },
{ 37, 254 },
{ 38, 252 },
{ 39, 251 },
{ 40, 250 },
{ 41, 249 },
{ 42, 248 },
{ 43, 246 },
{ 44, 245 },
{ 45, 244 },
{ 46, 242 },
{ 47, 241 },
{ 48, 240 },
{ 50, 239 },
{ 51, 238 },
{ 53, 237 },
{ 54, 236 },
{ 56, 235 },
{ 57, 234 },
{ 59, 233 },
{ 60, 232 },
{ 62, 231 },
{ 63, 230 },
{ 65, 229 },
{ 67, 228 },
{ 68, 227 },
{ 70, 226 },
{ 71, 225 },
{ 73, 224 },
{ 74, 223 },
{ 76, 222 },
{ 78, 221 },
{ 80, 220 },
{ 82, 219 },
{ 85, 218 },
{ 88, 217 },
{ 90, 216 },
{ 92, 215 },
{ 93, 214 },
{ 94, 212 },
{ 95, 211 },
{ 97, 210 },
{ 99, 209 },
{ 101, 208 },
{ 102, 207 },
{ 104, 206 },
{ 107, 205 },
{ 111, 204 },
{ 114, 203 },
{ 118, 202 },
{ 122, 201 },
{ 125, 200 },
{ 128, 199 },
{ 130, 198 },
{ 132, 197 },
{ 256, 190 },
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: au8522reg.h,v 1.1 2010/12/27 15:42:11 jmcneill Exp $ */
/* $NetBSD: au8522reg.h,v 1.2 2011/07/10 00:47:34 jmcneill Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill@invisible.ca>
@ -80,5 +80,7 @@
#define AU8522_REG_VFCOEF_CVBS 0x0415
#define AU8522_REG_AUDIO_FREQ 0x0606
#define AU8522_REG_LPFCOEF_BASE 0x060b
#define AU8522_REG_SNR_QAM 0x4522
#define AU8522_REG_SNR_VSB 0x4311
#endif /* !_AU8522REG_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: au8522var.h,v 1.3 2011/07/09 15:00:44 jmcneill Exp $ */
/* $NetBSD: au8522var.h,v 1.4 2011/07/10 00:47:34 jmcneill Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill@invisible.ca>
@ -67,5 +67,6 @@ void au8522_set_audio(struct au8522 *, bool);
int au8522_set_modulation(struct au8522 *, fe_modulation_t);
void au8522_set_gate(struct au8522 *, bool);
fe_status_t au8522_get_dtv_status(struct au8522 *);
uint16_t au8522_get_snr(struct au8522 *);
#endif /* !_AU8522VAR_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: auvitek_dtv.c,v 1.1 2011/07/09 15:00:44 jmcneill Exp $ */
/* $NetBSD: auvitek_dtv.c,v 1.2 2011/07/10 00:47:34 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.1 2011/07/09 15:00:44 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.2 2011/07/10 00:47:34 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -190,13 +190,15 @@ auvitek_dtv_get_status(void *priv)
uint16_t
auvitek_dtv_get_signal_strength(void *priv)
{
return 0; /* TODO */
return auvitek_dtv_get_snr(priv);
}
uint16_t
auvitek_dtv_get_snr(void *priv)
{
return 0; /* TODO */
struct auvitek_softc *sc = priv;
return au8522_get_snr(sc->sc_au8522);
}
static int