From nobody Sat May 10 05:57:25 2025 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1606216110; cv=none; d=zohomail.com; s=zohoarc; b=dpfM4SKQ2LRxaHTdWG1Ugk991WD67tg/mUUVhKKNJC6Ux/YOod6FVmmzkIFWQ4vSC1GG4OQo9yqRVeIoxQtz/SdWhMZQrIYNq/bsUzZt+YSwOGiZ5sg3/waKvAccc9/YkvQtDQBxmas7gFVrz5VJF3YqyR3XoUvADItciXt/hhk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606216110; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XgfhCGcZdKOWIpLHTNoBd5zG8cYoNaVtW8RHHPmvbK4=; b=RWDYJKFrIuuF7Djp5UlIYgaYHBKrDUuqoE6majDR/V3Hs+t6pDBCQpWFlN6H/6lVwKi2jJ7+9VnGXDVQdcnAD3wgwVEwYeXtGxcQ1onit6JSuj41MXQwZokUdK7JM/jI3F27bMkRbOEYnKdVS7v1Dx5V3ybRWBC2gPi9LeSiAMA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 1606216110578382.4343444018617; Tue, 24 Nov 2020 03:08:30 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732722AbgKXLH0 (ORCPT ); Tue, 24 Nov 2020 06:07:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:33802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732478AbgKXLGf (ORCPT ); Tue, 24 Nov 2020 06:06:35 -0500 Received: from mail.kernel.org (ip5f5ad5c3.dynamic.kabel-deutschland.de [95.90.213.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E9E220C56; Tue, 24 Nov 2020 11:06:31 +0000 (UTC) Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1khW9V-000FaA-38; Tue, 24 Nov 2020 12:06:29 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606215991; bh=mSCbc3vL0OUX7iyPLgs3eJ/2EFx5dLTtpikJrDdQUII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pnAa8VuUi02monrp10DHFGtpF/BK6Gj4KQuojdHQ8FfdZbq8fAlepQu7MbHzjZIcJ Rd5fcFUKNDxY0702bol9TxRYo7UCQ1AD+aP3xb3Hytwz9CeKF4dB3RKRRsVLl96BPe 9k6hiM3VIanqRqqOdMs7ZccRnOv+zYJAzhaCfcFg= From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , "Daniel W. S. Almeida" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 19/31] media: vidtv: add date to the current event Date: Tue, 24 Nov 2020 12:06:15 +0100 Message-Id: <6903ce43bd507de685ac97e18aed8e0dc1f76c33.1606215584.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The current event is using an undefined date. Instead, it should be the timestamp when the EIT table was generated. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/test-drivers/vidtv/vidtv_psi.c | 44 ++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/media/test-drivers/vidtv/vidtv_psi.c b/drivers/media/t= est-drivers/vidtv/vidtv_psi.c index 77bb560342a6..92fdf1149f0d 100644 --- a/drivers/media/test-drivers/vidtv/vidtv_psi.c +++ b/drivers/media/test-drivers/vidtv/vidtv_psi.c @@ -11,13 +11,16 @@ =20 #define pr_fmt(fmt) KBUILD_MODNAME ":%s, %d: " fmt, __func__, __LINE__ =20 +#include #include #include +#include #include #include #include #include #include +#include #include =20 #include "vidtv_common.h" @@ -1953,16 +1956,51 @@ u32 vidtv_psi_eit_write_into(struct vidtv_psi_eit_w= rite_args args) struct vidtv_psi_table_eit_event *vidtv_psi_eit_event_init(struct vidtv_psi_table_eit_event *head, u16 even= t_id) { - const u8 DURATION_ONE_HOUR[] =3D {1, 0, 0}; + const u8 DURATION[] =3D {0x23, 0x59, 0x59}; /* BCD encoded */ struct vidtv_psi_table_eit_event *e; + struct timespec64 ts; + struct tm time; + int mjd, l; + __be16 mjd_be; =20 e =3D kzalloc(sizeof(*e), GFP_KERNEL); if (!e) return NULL; =20 e->event_id =3D cpu_to_be16(event_id); - memset(e->start_time, 0xff, sizeof(e->start_time)); //todo: 0xff means 'u= nspecified' - memcpy(e->duration, DURATION_ONE_HOUR, sizeof(e->duration)); //todo, defa= ult to this for now + + ts =3D ktime_to_timespec64(ktime_get_real()); + time64_to_tm(ts.tv_sec, 0, &time); + + /* Convert date to Modified Julian Date - per EN 300 468 Annex C */ + if (time.tm_mon < 2) + l =3D 1; + else + l =3D 0; + + mjd =3D 14956 + time.tm_mday; + mjd +=3D (time.tm_year - l) * 36525 / 100; + mjd +=3D (time.tm_mon + 2 + l * 12) *306001 / 10000; + mjd_be =3D cpu_to_be16(mjd); + + /* + * Store MJD and hour/min/sec to the event. + * + * Let's make the event to start on a full hour + */ + memcpy(e->start_time, &mjd_be, sizeof(mjd_be)); + e->start_time[2] =3D bin2bcd(time.tm_hour); + e->start_time[3] =3D 0; + e->start_time[4] =3D 0; + + /* + * TODO: for now, the event will last for a day. Should be + * enough for testing purposes, but if one runs the driver + * for more than that, the current event will become invalid. + * So, we need a better code here in order to change the start + * time once the event expires. + */ + memcpy(e->duration, DURATION, sizeof(e->duration)); =20 e->bitfield =3D cpu_to_be16(RUNNING << 13); =20 --=20 2.28.0