From patchwork Fri Apr 26 14:22:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 2493981 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 9A83FDF230 for ; Fri, 26 Apr 2013 14:22:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753246Ab3DZOWy (ORCPT ); Fri, 26 Apr 2013 10:22:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14256 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752980Ab3DZOWx (ORCPT ); Fri, 26 Apr 2013 10:22:53 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3QEMr9C003989 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Apr 2013 10:22:53 -0400 Received: from pedra (vpn1-7-208.gru2.redhat.com [10.97.7.208]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3QEMph1030115 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 26 Apr 2013 10:22:53 -0400 Received: from v4l by pedra with local (Exim 4.80.1) (envelope-from ) id 1UVjY3-0007NA-25; Fri, 26 Apr 2013 11:22:51 -0300 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List Subject: [PATCH v2 2/2] saa7115: add detection code for gm7113c Date: Fri, 26 Apr 2013 11:22:48 -0300 Message-Id: <1366986168-27756-2-git-send-email-mchehab@redhat.com> In-Reply-To: <1366986168-27756-1-git-send-email-mchehab@redhat.com> References: <366980557-23077-1-git-send-email-mchehab@redhat.com> <1366986168-27756-1-git-send-email-mchehab@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Adds a code that (auto)detects gm7113c clones. The auto-detection here is not perfect, as, on contrary to what it would be expected by looking into its datasheets some devices would return, instead: saa7115 0-0025: chip 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 @ 0x4a is unknown (found on a device labeled as GM7113C 1145 by Ezequiel Garcia) Signed-off-by: Mauro Carvalho Chehab Tested-by: Jon Arne Jørgensen Tested-by: Ezequiel Garcia --- drivers/media/i2c/saa7115.c | 36 ++++++++++++++++++++++++++++++++++++ include/media/v4l2-chip-ident.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index 9340e0c..950a536 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c @@ -1640,6 +1640,36 @@ static int saa711x_detect_chip(struct i2c_client *client, } } + /* Check if it is a gm7113c */ + if (!memcmp(name, "0000", 4)) { + chip_id = 0; + for (i = 0; i < 4; i++) { + chip_id = chip_id << 1; + chip_id |= (chip_ver[i] & 0x80) ? 1 : 0; + } + + /* + * Note: From the datasheet, only versions 1 and 2 + * exists. However, tests on a device labeled as: + * "GM7113C 1145" returned "10" on all 16 chip + * version (reg 0x00) reads. So, we need to also + * accept at least verion 0. For now, let's just + * assume that a device that returns "0000" for + * the lower nibble is a gm7113c. + */ + + strlcpy(name, "gm7113c", size); + + if (!autodetect && strcmp(name, id->name)) + return -EINVAL; + + v4l_dbg(1, debug, client, + "It seems to be a %s chip (%*ph) @ 0x%x.\n", + name, 16, chip_ver, client->addr << 1); + + return V4L2_IDENT_GM7113C; + } + /* Chip was not discovered. Return its ID and don't bind */ v4l_dbg(1, debug, client, "chip %*ph @ 0x%x is unknown.\n", 16, chip_ver, client->addr << 1); @@ -1669,6 +1699,11 @@ 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); @@ -1756,6 +1791,7 @@ static const struct i2c_device_id saa711x_id[] = { { "saa7114", 0 }, { "saa7115", 0 }, { "saa7118", 0 }, + { "gm7113c", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, saa711x_id); diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h index c259b36..543f89c 100644 --- a/include/media/v4l2-chip-ident.h +++ b/include/media/v4l2-chip-ident.h @@ -52,6 +52,8 @@ enum { V4L2_IDENT_SAA7115 = 105, V4L2_IDENT_SAA7118 = 108, + V4L2_IDENT_GM7113C = 140, + /* module saa7127: reserved range 150-199 */ V4L2_IDENT_SAA7127 = 157, V4L2_IDENT_SAA7129 = 159,