From patchwork Thu Sep 22 00:04:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Utkin X-Patchwork-Id: 9344381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CAE50601C2 for ; Thu, 22 Sep 2016 00:04:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D121A2A40D for ; Thu, 22 Sep 2016 00:04:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5DBC2A414; Thu, 22 Sep 2016 00:04:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B43D62A40D for ; Thu, 22 Sep 2016 00:04:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934540AbcIVAEb (ORCPT ); Wed, 21 Sep 2016 20:04:31 -0400 Received: from mail-lf0-f42.google.com ([209.85.215.42]:33270 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934461AbcIVAEa (ORCPT ); Wed, 21 Sep 2016 20:04:30 -0400 Received: by mail-lf0-f42.google.com with SMTP id b71so28072136lfg.0 for ; Wed, 21 Sep 2016 17:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corp-bluecherry-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=17fbFCKUxC5/G5NzGt7PoU4NAMRxqFIFy+YLnPgFfJ0=; b=WadmXQvHApjJc8M8QtB7Z74YyG25yDMM0v7e/e2oXRHtIR8ezNI2AC9//BJAr5ZHd6 leYHSHWkEbrOsGBj2ec9gX4Ijvaq6UiDY6VOfgar+9je+QiP3ASNhBqunhyLwUnAc1Ey olVETFwcE4uPbxQXDVq8BYIE9GKnDRSAFPHU0GpKfgBuA+KhiY/gV268FASIW2u6bJJ8 udQjLmY/hDmsoNeWVTcRIr6Yfexaer36xsXsNeACdFpBwiE6UCpm6kVDEw+M3cbdPCX7 XSfwBs9T4XW7D1Z3PkvVvtXqQ+KYQBenxIzhLEqhiSFXlnbWNoq7vsFgvYXwy0vD0Qzk 0lOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=17fbFCKUxC5/G5NzGt7PoU4NAMRxqFIFy+YLnPgFfJ0=; b=MFTXQnMgwB2V1pITvgde3RYQiJaZM/w/vm4rdwy/cpIh5WPVBPYljwrkx9/2BwFTX7 3vMN4n8jAoHtzeBFpLGFK/WStki9E0QpYeyvoazp5XAX31Yon2Vx+WqOkGh9qGvVo8Mj RMtSf3V3Iq1ihPy0K3Xiil8s6xX8f2fV0q4ifeozTzIKNBkU4tAoGqDPexff0bIEKd7P dkC4Ccjq40r2xLInHQF5U+or2KFcoNiodCjpUWgZnP+gcQl14OchABgpHN5cA7wlA1kG db/2ouoX10jJ2xs1rHGQKXIrh5Tkg8SNCZ6Fo2CPJRraWIPU7xhdRpEfA5ApErxqc84P 4o1g== X-Gm-Message-State: AE9vXwN+2n85AZ/4M7/NB1gPDN4zU806LYmEAsLvU5Bx05T9nu4GWQqF14XyiSVcE5Ei3cAd X-Received: by 10.46.0.98 with SMTP id 95mr15116241lja.35.1474502668459; Wed, 21 Sep 2016 17:04:28 -0700 (PDT) Received: from localhost.localdomain ([91.198.4.228]) by smtp.gmail.com with ESMTPSA id 5sm6989489ljb.22.2016.09.21.17.04.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Sep 2016 17:04:27 -0700 (PDT) From: Andrey Utkin To: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: maintainers@bluecherrydvr.com, andrey_utkin@fastmail.com, Andrey Utkin Subject: [PATCH] [media] tw5864: crop picture width to 704 Date: Thu, 22 Sep 2016 03:04:20 +0300 Message-Id: <20160922000420.4273-1-andrey.utkin@corp.bluecherry.net> X-Mailer: git-send-email 2.9.2 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previously, width of 720 was used, but it gives 16-pixel wide black bar at right side of encoded picture. Signed-off-by: Andrey Utkin --- drivers/media/pci/tw5864/tw5864-reg.h | 8 ++++++++ drivers/media/pci/tw5864/tw5864-video.c | 13 +++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/tw5864/tw5864-reg.h b/drivers/media/pci/tw5864/tw5864-reg.h index 92a1b07..30ac142 100644 --- a/drivers/media/pci/tw5864/tw5864-reg.h +++ b/drivers/media/pci/tw5864/tw5864-reg.h @@ -1879,6 +1879,14 @@ #define TW5864_INDIR_IN_PIC_HEIGHT(channel) (0x201 + 4 * channel) #define TW5864_INDIR_OUT_PIC_WIDTH(channel) (0x202 + 4 * channel) #define TW5864_INDIR_OUT_PIC_HEIGHT(channel) (0x203 + 4 * channel) + +/* Some registers skipped */ + +#define TW5864_INDIR_CROP_ETC 0x260 +/* Define controls in register TW5864_INDIR_CROP_ETC */ +/* Enable cropping from 720 to 704 */ +#define TW5864_INDIR_CROP_ETC_CROP_EN 0x4 + /* * Interrupt status register from the front-end. Write "1" to each bit to clear * the interrupt diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c index ff94e6c..3c8c302 100644 --- a/drivers/media/pci/tw5864/tw5864-video.c +++ b/drivers/media/pci/tw5864/tw5864-video.c @@ -590,6 +590,15 @@ static int tw5864_enable_input(struct tw5864_input *input) tw_indir_writeb(TW5864_INDIR_OUT_PIC_WIDTH(nr), input->width / 4); tw_indir_writeb(TW5864_INDIR_OUT_PIC_HEIGHT(nr), input->height / 4); + /* + * Crop width from 720 to 704. + * Above register settings need value 720 involved. + */ + input->width = 704; + tw_indir_writeb(TW5864_INDIR_CROP_ETC, + tw_indir_readb(TW5864_INDIR_CROP_ETC) | + TW5864_INDIR_CROP_ETC_CROP_EN); + tw_writel(TW5864_DSP_PIC_MAX_MB, ((input->width / 16) << 8) | (input->height / 16)); @@ -792,7 +801,7 @@ static int tw5864_fmt_vid_cap(struct file *file, void *priv, { struct tw5864_input *input = video_drvdata(file); - f->fmt.pix.width = 720; + f->fmt.pix.width = 704; switch (input->std) { default: WARN_ON_ONCE(1); @@ -998,7 +1007,7 @@ static int tw5864_enum_framesizes(struct file *file, void *priv, return -EINVAL; fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; - fsize->discrete.width = 720; + fsize->discrete.width = 704; fsize->discrete.height = input->std == STD_NTSC ? 480 : 576; return 0;