From patchwork Fri May 3 08:11:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jon_Arne_J=C3=B8rgensen?= X-Patchwork-Id: 2516241 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 54915DF2E5 for ; Fri, 3 May 2013 08:09:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758995Ab3ECIJS (ORCPT ); Fri, 3 May 2013 04:09:18 -0400 Received: from cm-84.215.157.11.getinternet.no ([84.215.157.11]:43750 "EHLO server.arpanet.local" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1762759Ab3ECII7 (ORCPT ); Fri, 3 May 2013 04:08:59 -0400 Received: from dell.arpanet.local (unknown [172.27.27.20]) by server.arpanet.local (Postfix) with ESMTP id E6B8815F2A; Fri, 3 May 2013 10:10:33 +0200 (CEST) Received: by dell.arpanet.local (Postfix, from userid 1000) id 1348E300764; Fri, 3 May 2013 10:11:59 +0200 (CEST) From: =?UTF-8?q?Jon=20Arne=20J=C3=B8rgensen?= To: mchehab@redhat.com Cc: ezequiel.garcia@free-electrons.com, linux-media@vger.kernel.org, jonjon.arnearne@gmail.com Subject: [PATCH V4 3/3] saa7115: Add register setup and config for gm7113c Date: Fri, 3 May 2013 10:11:58 +0200 Message-Id: <1367568718-4129-4-git-send-email-jonarne@jonarne.no> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1367568718-4129-1-git-send-email-jonarne@jonarne.no> References: <1367568718-4129-1-git-send-email-jonarne@jonarne.no> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The gm7113c chip is similar to the original saa7113 chip, so I try to re-use most of the saa7113 specific setup-/configuration registers. According to the datasheet, the gm7113c chip has not implemented any register addresses after 0x1f, so I add a new entry for the chip in the saa711x_has_reg function. The devices I've seen using this chip will fail to get stable video-sync if these registers are not zeroed: R_14_ANAL_ADC_COMPAT_CNTL R_15_VGATE_START_FID_CHG R_16_VGATE_STOP R_17_MISC_VGATE_CONF_AND_MSB The saa711x_set_v4lstd is updated to send a simpler configuration-table to avoid setting these registers. Signed-off-by: Jon Arne Jørgensen Tested-by: Ezequiel Garcia --- drivers/media/i2c/saa7115.c | 47 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index eb2c19d..efdc7fd 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c @@ -126,6 +126,8 @@ static int saa711x_has_reg(const int id, const u8 reg) return 0; switch (id) { + case V4L2_IDENT_GM7113C: + return reg != 0x14 && (reg < 0x18 || reg > 0x1e) && reg < 0x20; case V4L2_IDENT_SAA7113: return reg != 0x14 && (reg < 0x18 || reg > 0x1e) && (reg < 0x20 || reg > 0x3f) && reg != 0x5d && reg < 0x63; @@ -213,7 +215,10 @@ static const unsigned char saa7111_init[] = { 0x00, 0x00 }; -/* SAA7113 init codes */ +/* SAA7113/GM7113C init codes + * It's important that R_14... R_17 == 0x00 + * for the gm7113c chip to deliver stable video + */ static const unsigned char saa7113_init[] = { R_01_INC_DELAY, 0x08, R_02_INPUT_CNTL_1, 0xc2, @@ -447,6 +452,24 @@ static const unsigned char saa7115_cfg_50hz_video[] = { /* ============== SAA7715 VIDEO templates (end) ======= */ +/* ============== GM7113C VIDEO templates ============= */ +static const unsigned char gm7113c_cfg_60hz_video[] = { + R_08_SYNC_CNTL, 0x68, /* 0xBO: auto detection, 0x68 = NTSC */ + R_0E_CHROMA_CNTL_1, 0x07, /* video autodetection is on */ + + 0x00, 0x00 +}; + +static const unsigned char gm7113c_cfg_50hz_video[] = { + R_08_SYNC_CNTL, 0x28, /* 0x28 = PAL */ + R_0E_CHROMA_CNTL_1, 0x07, + + 0x00, 0x00 +}; + +/* ============== GM7113C VIDEO templates (end) ======= */ + + static const unsigned char saa7115_cfg_vbi_on[] = { R_80_GLOBAL_CNTL_1, 0x00, /* reset tasks */ R_88_POWER_SAVE_ADC_PORT_CNTL, 0xd0, /* reset scaler */ @@ -927,11 +950,17 @@ static void saa711x_set_v4lstd(struct v4l2_subdev *sd, v4l2_std_id std) // This works for NTSC-M, SECAM-L and the 50Hz PAL variants. if (std & V4L2_STD_525_60) { v4l2_dbg(1, debug, sd, "decoder set standard 60 Hz\n"); - saa711x_writeregs(sd, saa7115_cfg_60hz_video); + if (state->ident == V4L2_IDENT_GM7113C) + saa711x_writeregs(sd, gm7113c_cfg_60hz_video); + else + saa711x_writeregs(sd, saa7115_cfg_60hz_video); saa711x_set_size(sd, 720, 480); } else { v4l2_dbg(1, debug, sd, "decoder set standard 50 Hz\n"); - saa711x_writeregs(sd, saa7115_cfg_50hz_video); + if (state->ident == V4L2_IDENT_GM7113C) + saa711x_writeregs(sd, gm7113c_cfg_50hz_video); + else + saa711x_writeregs(sd, saa7115_cfg_50hz_video); saa711x_set_size(sd, 720, 576); } @@ -944,7 +973,8 @@ static void saa711x_set_v4lstd(struct v4l2_subdev *sd, v4l2_std_id std) 011 NTSC N (3.58MHz) PAL M (3.58MHz) 100 reserved NTSC-Japan (3.58MHz) */ - if (state->ident <= V4L2_IDENT_SAA7113) { + if (state->ident <= V4L2_IDENT_SAA7113 || + state->ident == V4L2_IDENT_GM7113C) { u8 reg = saa711x_read(sd, R_0E_CHROMA_CNTL_1) & 0x8f; if (std == V4L2_STD_PAL_M) { @@ -1215,7 +1245,8 @@ static int saa711x_s_routing(struct v4l2_subdev *sd, input, output); /* saa7111/3 does not have these inputs */ - if (state->ident <= V4L2_IDENT_SAA7113 && + if ((state->ident <= V4L2_IDENT_SAA7113 || + state->ident == V4L2_IDENT_GM7113C) && (input == SAA7115_COMPOSITE4 || input == SAA7115_COMPOSITE5)) { return -EINVAL; @@ -1687,11 +1718,6 @@ static int saa711x_probe(struct i2c_client *client, if (ident < 0) return ident; - if (ident == V4L2_IDENT_GM7113C) { - v4l_warn(client, "%s not yet supported\n", name); - return -ENODEV; - } - strlcpy(client->name, name, sizeof(client->name)); state = kzalloc(sizeof(struct saa711x_state), GFP_KERNEL); @@ -1742,6 +1768,7 @@ static int saa711x_probe(struct i2c_client *client, case V4L2_IDENT_SAA7111A: saa711x_writeregs(sd, saa7111_init); break; + case V4L2_IDENT_GM7113C: case V4L2_IDENT_SAA7113: saa711x_writeregs(sd, saa7113_init); break;