From patchwork Sun Dec 12 18:33:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 401402 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBCIXXF6021147 for ; Sun, 12 Dec 2010 18:33:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753672Ab0LLSd0 (ORCPT ); Sun, 12 Dec 2010 13:33:26 -0500 Received: from smtp-vbr15.xs4all.nl ([194.109.24.35]:4678 "EHLO smtp-vbr15.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753548Ab0LLSd0 (ORCPT ); Sun, 12 Dec 2010 13:33:26 -0500 Received: from tschai.localnet (159.80-203-19.nextgentel.com [80.203.19.159]) (authenticated bits=0) by smtp-vbr15.xs4all.nl (8.13.8/8.13.8) with ESMTP id oBCIXMEI025461 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 12 Dec 2010 19:33:23 +0100 (CET) (envelope-from hverkuil@xs4all.nl) From: Hans Verkuil To: Andy Walls Subject: Re: [RFC/PATCH 03/19] cx18: Use the control framework. Date: Sun, 12 Dec 2010 19:33:21 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.37-rc2-tschai; KDE/4.4.5; x86_64; ; ) Cc: linux-media@vger.kernel.org References: <8lcku8q5u511tsmore3i7sls.1292177376794@email.android.com> In-Reply-To: <8lcku8q5u511tsmore3i7sls.1292177376794@email.android.com> MIME-Version: 1.0 Message-Id: <201012121933.21498.hverkuil@xs4all.nl> X-Virus-Scanned: by XS4ALL Virus Scanner Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sun, 12 Dec 2010 18:33:33 +0000 (UTC) diff --git a/drivers/media/video/cx18/cx18-av-core.c b/drivers/media/video/cx18/cx18-av-core.c index e1f58f1..73b6f4d 100644 --- a/drivers/media/video/cx18/cx18-av-core.c +++ b/drivers/media/video/cx18/cx18-av-core.c @@ -248,8 +248,22 @@ static void cx18_av_initialize(struct v4l2_subdev *sd) /* CxDevWrReg(CXADEC_SRC_COMB_CFG, 0x6628021F); */ /* } */ cx18_av_write4(cx, CXADEC_SRC_COMB_CFG, 0x6628021F); - default_volume = 228 - cx18_av_read(cx, 0x8d4); - default_volume = ((default_volume / 2) + 23) << 9; + default_volume = cx18_av_read(cx, 0x8d4); + /* + * Enforce the legacy volume scale mapping limits to avoid -ERANGE + * errors when initializing the volume control + */ + if (default_volume > 228) { + /* Bottom out at -96 dB, v4l2 vol range 0x2e00-0x2fff */ + default_volume = 228; + cx18_av_write(cx, 0x8d4, 228); + } + else if (default_volume < 20) { + /* Top out at + 8 dB, v4l2 vol range 0xfe00-0xffff */ + default_volume = 20; + cx18_av_write(cx, 0x8d4, 20); + } + default_volume = (((228 - default_volume) >> 1) + 23) << 9; state->volume->cur.val = state->volume->default_value = default_volume; v4l2_ctrl_handler_setup(&state->hdl); } @@ -1359,7 +1373,7 @@ int cx18_av_probe(struct cx18 *cx) state->volume = v4l2_ctrl_new_std(&state->hdl, &cx18_av_audio_ctrl_ops, V4L2_CID_AUDIO_VOLUME, - 0, 65335, 65535 / 100, 0); + 0, 65535, 65535 / 100, 0); v4l2_ctrl_new_std(&state->hdl, &cx18_av_audio_ctrl_ops, V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);