diff options
Diffstat (limited to 'drivers/media/video/cx18/cx18-av-audio.c')
-rw-r--r-- | drivers/media/video/cx18/cx18-av-audio.c | 92 |
1 files changed, 12 insertions, 80 deletions
diff --git a/drivers/media/video/cx18/cx18-av-audio.c b/drivers/media/video/cx18/cx18-av-audio.c index 43d09a24b262..4a24ffb17a7d 100644 --- a/drivers/media/video/cx18/cx18-av-audio.c +++ b/drivers/media/video/cx18/cx18-av-audio.c | |||
@@ -342,17 +342,6 @@ void cx18_av_audio_set_path(struct cx18 *cx) | |||
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | static int get_volume(struct cx18 *cx) | ||
346 | { | ||
347 | /* Volume runs +18dB to -96dB in 1/2dB steps | ||
348 | * change to fit the msp3400 -114dB to +12dB range */ | ||
349 | |||
350 | /* check PATH1_VOLUME */ | ||
351 | int vol = 228 - cx18_av_read(cx, 0x8d4); | ||
352 | vol = (vol / 2) + 23; | ||
353 | return vol << 9; | ||
354 | } | ||
355 | |||
356 | static void set_volume(struct cx18 *cx, int volume) | 345 | static void set_volume(struct cx18 *cx, int volume) |
357 | { | 346 | { |
358 | /* First convert the volume to msp3400 values (0-127) */ | 347 | /* First convert the volume to msp3400 values (0-127) */ |
@@ -369,52 +358,18 @@ static void set_volume(struct cx18 *cx, int volume) | |||
369 | cx18_av_write(cx, 0x8d4, 228 - (vol * 2)); | 358 | cx18_av_write(cx, 0x8d4, 228 - (vol * 2)); |
370 | } | 359 | } |
371 | 360 | ||
372 | static int get_bass(struct cx18 *cx) | ||
373 | { | ||
374 | /* bass is 49 steps +12dB to -12dB */ | ||
375 | |||
376 | /* check PATH1_EQ_BASS_VOL */ | ||
377 | int bass = cx18_av_read(cx, 0x8d9) & 0x3f; | ||
378 | bass = (((48 - bass) * 0xffff) + 47) / 48; | ||
379 | return bass; | ||
380 | } | ||
381 | |||
382 | static void set_bass(struct cx18 *cx, int bass) | 361 | static void set_bass(struct cx18 *cx, int bass) |
383 | { | 362 | { |
384 | /* PATH1_EQ_BASS_VOL */ | 363 | /* PATH1_EQ_BASS_VOL */ |
385 | cx18_av_and_or(cx, 0x8d9, ~0x3f, 48 - (bass * 48 / 0xffff)); | 364 | cx18_av_and_or(cx, 0x8d9, ~0x3f, 48 - (bass * 48 / 0xffff)); |
386 | } | 365 | } |
387 | 366 | ||
388 | static int get_treble(struct cx18 *cx) | ||
389 | { | ||
390 | /* treble is 49 steps +12dB to -12dB */ | ||
391 | |||
392 | /* check PATH1_EQ_TREBLE_VOL */ | ||
393 | int treble = cx18_av_read(cx, 0x8db) & 0x3f; | ||
394 | treble = (((48 - treble) * 0xffff) + 47) / 48; | ||
395 | return treble; | ||
396 | } | ||
397 | |||
398 | static void set_treble(struct cx18 *cx, int treble) | 367 | static void set_treble(struct cx18 *cx, int treble) |
399 | { | 368 | { |
400 | /* PATH1_EQ_TREBLE_VOL */ | 369 | /* PATH1_EQ_TREBLE_VOL */ |
401 | cx18_av_and_or(cx, 0x8db, ~0x3f, 48 - (treble * 48 / 0xffff)); | 370 | cx18_av_and_or(cx, 0x8db, ~0x3f, 48 - (treble * 48 / 0xffff)); |
402 | } | 371 | } |
403 | 372 | ||
404 | static int get_balance(struct cx18 *cx) | ||
405 | { | ||
406 | /* balance is 7 bit, 0 to -96dB */ | ||
407 | |||
408 | /* check PATH1_BAL_LEVEL */ | ||
409 | int balance = cx18_av_read(cx, 0x8d5) & 0x7f; | ||
410 | /* check PATH1_BAL_LEFT */ | ||
411 | if ((cx18_av_read(cx, 0x8d5) & 0x80) == 0) | ||
412 | balance = 0x80 - balance; | ||
413 | else | ||
414 | balance = 0x80 + balance; | ||
415 | return balance << 8; | ||
416 | } | ||
417 | |||
418 | static void set_balance(struct cx18 *cx, int balance) | 373 | static void set_balance(struct cx18 *cx, int balance) |
419 | { | 374 | { |
420 | int bal = balance >> 8; | 375 | int bal = balance >> 8; |
@@ -431,12 +386,6 @@ static void set_balance(struct cx18 *cx, int balance) | |||
431 | } | 386 | } |
432 | } | 387 | } |
433 | 388 | ||
434 | static int get_mute(struct cx18 *cx) | ||
435 | { | ||
436 | /* check SRC1_MUTE_EN */ | ||
437 | return cx18_av_read(cx, 0x8d3) & 0x2 ? 1 : 0; | ||
438 | } | ||
439 | |||
440 | static void set_mute(struct cx18 *cx, int mute) | 389 | static void set_mute(struct cx18 *cx, int mute) |
441 | { | 390 | { |
442 | struct cx18_av_state *state = &cx->av_state; | 391 | struct cx18_av_state *state = &cx->av_state; |
@@ -490,50 +439,33 @@ int cx18_av_s_clock_freq(struct v4l2_subdev *sd, u32 freq) | |||
490 | return retval; | 439 | return retval; |
491 | } | 440 | } |
492 | 441 | ||
493 | int cx18_av_audio_g_ctrl(struct cx18 *cx, struct v4l2_control *ctrl) | 442 | static int cx18_av_audio_s_ctrl(struct v4l2_ctrl *ctrl) |
494 | { | 443 | { |
495 | switch (ctrl->id) { | 444 | struct v4l2_subdev *sd = to_sd(ctrl); |
496 | case V4L2_CID_AUDIO_VOLUME: | 445 | struct cx18 *cx = v4l2_get_subdevdata(sd); |
497 | ctrl->value = get_volume(cx); | ||
498 | break; | ||
499 | case V4L2_CID_AUDIO_BASS: | ||
500 | ctrl->value = get_bass(cx); | ||
501 | break; | ||
502 | case V4L2_CID_AUDIO_TREBLE: | ||
503 | ctrl->value = get_treble(cx); | ||
504 | break; | ||
505 | case V4L2_CID_AUDIO_BALANCE: | ||
506 | ctrl->value = get_balance(cx); | ||
507 | break; | ||
508 | case V4L2_CID_AUDIO_MUTE: | ||
509 | ctrl->value = get_mute(cx); | ||
510 | break; | ||
511 | default: | ||
512 | return -EINVAL; | ||
513 | } | ||
514 | return 0; | ||
515 | } | ||
516 | 446 | ||
517 | int cx18_av_audio_s_ctrl(struct cx18 *cx, struct v4l2_control *ctrl) | ||
518 | { | ||
519 | switch (ctrl->id) { | 447 | switch (ctrl->id) { |
520 | case V4L2_CID_AUDIO_VOLUME: | 448 | case V4L2_CID_AUDIO_VOLUME: |
521 | set_volume(cx, ctrl->value); | 449 | set_volume(cx, ctrl->val); |
522 | break; | 450 | break; |
523 | case V4L2_CID_AUDIO_BASS: | 451 | case V4L2_CID_AUDIO_BASS: |
524 | set_bass(cx, ctrl->value); | 452 | set_bass(cx, ctrl->val); |
525 | break; | 453 | break; |
526 | case V4L2_CID_AUDIO_TREBLE: | 454 | case V4L2_CID_AUDIO_TREBLE: |
527 | set_treble(cx, ctrl->value); | 455 | set_treble(cx, ctrl->val); |
528 | break; | 456 | break; |
529 | case V4L2_CID_AUDIO_BALANCE: | 457 | case V4L2_CID_AUDIO_BALANCE: |
530 | set_balance(cx, ctrl->value); | 458 | set_balance(cx, ctrl->val); |
531 | break; | 459 | break; |
532 | case V4L2_CID_AUDIO_MUTE: | 460 | case V4L2_CID_AUDIO_MUTE: |
533 | set_mute(cx, ctrl->value); | 461 | set_mute(cx, ctrl->val); |
534 | break; | 462 | break; |
535 | default: | 463 | default: |
536 | return -EINVAL; | 464 | return -EINVAL; |
537 | } | 465 | } |
538 | return 0; | 466 | return 0; |
539 | } | 467 | } |
468 | |||
469 | const struct v4l2_ctrl_ops cx18_av_audio_ctrl_ops = { | ||
470 | .s_ctrl = cx18_av_audio_s_ctrl, | ||
471 | }; | ||