From patchwork Fri May 13 18:29:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Maidana X-Patchwork-Id: 12849233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADCE9C433FE for ; Fri, 13 May 2022 18:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383314AbiEMS3H (ORCPT ); Fri, 13 May 2022 14:29:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357047AbiEMS3F (ORCPT ); Fri, 13 May 2022 14:29:05 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D98220F5F for ; Fri, 13 May 2022 11:29:04 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id a22-20020a9d3e16000000b00606aeb12ab6so5509225otd.7 for ; Fri, 13 May 2022 11:29:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lIF7k4v5bkQ1JwCJMU++M6XdFQcBN0X2WTak6t2MkWY=; b=FknPh0u5sqhQDyh9PmSUYYHFewjY8FjSppva4LGSaX3q611p1YjOW6s7RUwiCJ0uwX 3q+FfvvqkjbBnXsYS3y+kT6Sh0V6fJ8l/eNNExZIBoH94omZflnn/5ZQ4BK8ms1iq48U rKWq4Vg3g9QscSAWbhEoPhUxO+HuqKGuKgn+AfAzA9e+PANQUD9PB2mSNb4woYsvQt78 2BwZ8+in4Ck7g1KsHrHRLR6/koCeGn+TJEW/WmakE/PSNeqt9DwHitbYkHJa7Pt/4qNa yqmT0HLlfhb9XjUHwpzwwokUiMgKgvViCT0rOS9o8BOyd4pjPpZF6G5Yk3PeuYOc2lJY GItw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lIF7k4v5bkQ1JwCJMU++M6XdFQcBN0X2WTak6t2MkWY=; b=KwlvbPRyQWx4t4Dlk6jP2bfk6cPqQMGsLVbe/bPYsmoKxKu8zL1VU8Xxw+n66HIxDJ dciJ9ItgZZ4Xw6Dp7so3KiW7hTdv+CcevfNFBB5X+iZ/ZfFjLQoNeDkM+80KsY8q+ZGa 1Nn7qd7XCl1YyJ5QSHXM585m66Pj5utWNS3o0CMFznJGC9I6LPhQssLukVRCffcrrETj IQ6EHaQI7toxnZXCWnh8zlkYhhpR48/EkwKOp0rtOoG9x7oEGOnvf1kUQvz/0hat+Qx4 lRo+ljaIInHB/6L8+QzDCMx2P/lf57sxP2JmUD69wE3xPEFylh2D5yITQGBkVV1a5KC1 1SdQ== X-Gm-Message-State: AOAM530KBGVv2RUfI+Fte2B8LbS9MC25kEiXGf/zqwDZw16aSD3yYypH pYu62o9h/ONKjZIyp02eHG8= X-Google-Smtp-Source: ABdhPJwpNLZcTYcttGznC1oxoDTDTX+DKZYBZKvJe5IJ6hZ9mEuTYZ8RBhPsydR3pWSv8KTVTfO9BA== X-Received: by 2002:a05:6830:43a8:b0:606:51a5:339f with SMTP id s40-20020a05683043a800b0060651a5339fmr2385884otv.62.1652466543471; Fri, 13 May 2022 11:29:03 -0700 (PDT) Received: from local.lan ([190.1.30.36]) by smtp.gmail.com with ESMTPSA id c24-20020a9d6858000000b00606ad72bdcbsm1234719oto.38.2022.05.13.11.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 11:29:03 -0700 (PDT) From: Jorge Maidana To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, Jorge Maidana Subject: [PATCH 1/2] media: cx88: Fix PAL-Nc standard Date: Fri, 13 May 2022 15:29:21 -0300 Message-Id: <20220513182922.4882-2-jorgem.linux@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220513182922.4882-1-jorgem.linux@gmail.com> References: <20220513182922.4882-1-jorgem.linux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org * Fix PAL-Nc horizontal parameters according to DScaler: https://github.com/JohnAdders/DScaler/blob/f7d92b76678e/DScaler/TVFormats.cpp#L88-L94 * Add PAL-Nc TV audio support. * Tested with CVBS and RF on a Pinnacle PCTV HD 800i. Signed-off-by: Jorge Maidana --- drivers/media/pci/cx88/cx88-core.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/media/pci/cx88/cx88-core.c b/drivers/media/pci/cx88/cx88-core.c index 89d4d5a3b..52be42f9a 100644 --- a/drivers/media/pci/cx88/cx88-core.c +++ b/drivers/media/pci/cx88/cx88-core.c @@ -618,12 +618,24 @@ EXPORT_SYMBOL(cx88_reset); static inline unsigned int norm_swidth(v4l2_std_id norm) { - return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922; + if (norm & (V4L2_STD_NTSC | V4L2_STD_PAL_M)) + return 754; + + if (norm & V4L2_STD_PAL_Nc) + return 745; + + return 922; } static inline unsigned int norm_hdelay(v4l2_std_id norm) { - return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 135 : 186; + if (norm & (V4L2_STD_NTSC | V4L2_STD_PAL_M)) + return 135; + + if (norm & V4L2_STD_PAL_Nc) + return 149; + + return 186; } static inline unsigned int norm_vdelay(v4l2_std_id norm) @@ -636,7 +648,7 @@ static inline unsigned int norm_fsc8(v4l2_std_id norm) if (norm & V4L2_STD_PAL_M) return 28604892; // 3.575611 MHz - if (norm & (V4L2_STD_PAL_Nc)) + if (norm & V4L2_STD_PAL_Nc) return 28656448; // 3.582056 MHz if (norm & V4L2_STD_NTSC) // All NTSC/M and variants @@ -841,8 +853,8 @@ static int set_tvaudio(struct cx88_core *core) } else if (V4L2_STD_SECAM_DK & norm) { core->tvaudio = WW_DK; - } else if ((V4L2_STD_NTSC_M & norm) || - (V4L2_STD_PAL_M & norm)) { + } else if ((V4L2_STD_NTSC_M | V4L2_STD_PAL_M | V4L2_STD_PAL_Nc) & + norm) { core->tvaudio = WW_BTSC; } else if (V4L2_STD_NTSC_M_JP & norm) { From patchwork Fri May 13 18:29:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Maidana X-Patchwork-Id: 12849234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19EA0C433EF for ; Fri, 13 May 2022 18:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383315AbiEMS3I (ORCPT ); Fri, 13 May 2022 14:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383154AbiEMS3H (ORCPT ); Fri, 13 May 2022 14:29:07 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 934821E3DF for ; Fri, 13 May 2022 11:29:05 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id v65so11078560oig.10 for ; Fri, 13 May 2022 11:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FebFG50y/hqQs8Aal2+HUzGUexEDNc7nBQTBDQlxscI=; b=BjfQDaB1gEyQ1pXnGhHohkS33y8DdGkGa3xSKJXbH+ynEvxIJ8YyQ+ytAhiJo36aMc 3xIpZNB7qoxAt3x4cKODMs4tmeDrGPI/XNory2ndKRLz5aqIAjqNIQJ7mcctJmI4aiJm 9I8prk98Hk5N2do/qjttFjE2WNz5Nl7wPPvE37JNkvb8B8t0jTftkqIxp5f8VihCbbFs ByizAjp5gkN/vfVbx169K2o9cn4CzW9R9EY6TiJ+grGQLcmnYAnGAMFChaiRTXc3WVUe C5f21WzE0fBeq3xJ/NmkUyVyr6ucjRdQDgNNhFw/NBjc4BCqIe17+bIMVDwbnTwX3K8O FP5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FebFG50y/hqQs8Aal2+HUzGUexEDNc7nBQTBDQlxscI=; b=eA9uikYmyfPhdLjM/EAg3TJAODgfJFAgPTTW+li7yAONGWiJ6H1EVVkA60sftkShwJ hQbvJH079ZTmtnb5da6LUpKFU5ea8uEBtZcqsov0RZs9I+ZDA+A/Pe2QM9dUBdFE0/1Y E3VgpOsLgtniaaQDk0F6TiwPSb8iK4UgpXcn/Uou+fsCYqCwsAclGSeprwwPBMqbFvio u5fBgsEhBwRSe0i8vUEVmgNOG9kwpdqTGY6OhxK1P0sHju647gong7DvZME24g7Hdvdp uHouW4u969AmY0A4IGtFMn7RgiPbGXxElt57AeOXeKeWj/ZzJqobduvdGMrNu16eqTj9 BIvQ== X-Gm-Message-State: AOAM531MMzq+6UyFJmbUl5l4ra7pNp2/z4hmkqowtZf1j5vC5+ClY5ca YdTx/G5V9Wac3St/AzgfrDc= X-Google-Smtp-Source: ABdhPJyclogfR5MGQlfNinAnO/L2u0ysXIFbLeS4S2//JAPJPIw66GGQhG6SwNCudY8ogFtiABEVfw== X-Received: by 2002:a05:6808:13d2:b0:328:a194:1d0e with SMTP id d18-20020a05680813d200b00328a1941d0emr8162385oiw.68.1652466544958; Fri, 13 May 2022 11:29:04 -0700 (PDT) Received: from local.lan ([190.1.30.36]) by smtp.gmail.com with ESMTPSA id c24-20020a9d6858000000b00606ad72bdcbsm1234719oto.38.2022.05.13.11.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 11:29:04 -0700 (PDT) From: Jorge Maidana To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, Jorge Maidana Subject: [PATCH 2/2] media: usbtv: Add PAL-Nc standard Date: Fri, 13 May 2022 15:29:22 -0300 Message-Id: <20220513182922.4882-3-jorgem.linux@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220513182922.4882-1-jorgem.linux@gmail.com> References: <20220513182922.4882-1-jorgem.linux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add PAL-Nc support to usbtv, the corresponding register value "0x00fe" comes from the Windows driver "Active Development Co., Ltd. v2.1.1.2". Signed-off-by: Jorge Maidana --- drivers/media/usb/usbtv/usbtv-video.c | 5 ++++- drivers/media/usb/usbtv/usbtv.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c index a714ad77c..1e30e0595 100644 --- a/drivers/media/usb/usbtv/usbtv-video.c +++ b/drivers/media/usb/usbtv/usbtv-video.c @@ -136,6 +136,8 @@ static uint16_t usbtv_norm_to_16f_reg(v4l2_std_id norm) return 0x00a8; if (norm & (V4L2_STD_PAL_M | V4L2_STD_PAL_60)) return 0x00bc; + if (norm & V4L2_STD_PAL_Nc) + return 0x00fe; /* Fallback to automatic detection for other standards */ return 0x0000; } @@ -241,7 +243,8 @@ static int usbtv_select_norm(struct usbtv *usbtv, v4l2_std_id norm) static const v4l2_std_id ntsc_mask = V4L2_STD_NTSC | V4L2_STD_NTSC_443; static const v4l2_std_id pal_mask = - V4L2_STD_PAL | V4L2_STD_PAL_60 | V4L2_STD_PAL_M; + V4L2_STD_PAL | V4L2_STD_PAL_60 | V4L2_STD_PAL_M | + V4L2_STD_PAL_Nc; if (norm & ntsc_mask) ret = usbtv_set_regs(usbtv, ntsc, ARRAY_SIZE(ntsc)); diff --git a/drivers/media/usb/usbtv/usbtv.h b/drivers/media/usb/usbtv/usbtv.h index 77a368e90..b9fa7c008 100644 --- a/drivers/media/usb/usbtv/usbtv.h +++ b/drivers/media/usb/usbtv/usbtv.h @@ -68,7 +68,8 @@ #define USBTV_ODD(chunk) ((be32_to_cpu(chunk[0]) & 0x0000f000) >> 15) #define USBTV_CHUNK_NO(chunk) (be32_to_cpu(chunk[0]) & 0x00000fff) -#define USBTV_TV_STD (V4L2_STD_525_60 | V4L2_STD_PAL | V4L2_STD_SECAM) +#define USBTV_TV_STD (V4L2_STD_525_60 | V4L2_STD_PAL | \ + V4L2_STD_PAL_Nc | V4L2_STD_SECAM) /* parameters for supported TV norms */ struct usbtv_norm_params {