Received: by 10.223.164.202 with SMTP id h10csp260132wrb; Wed, 22 Nov 2017 20:28:06 -0800 (PST) X-Google-Smtp-Source: AGs4zMbreTdvaUrz5Rg4GdunC5QqfKQrxvpUTyEO20G5UkUVTdZmoN0IVjZSTVEZTsqLA1TWZ4Ut X-Received: by 10.99.8.5 with SMTP id 5mr22918449pgi.28.1511411285922; Wed, 22 Nov 2017 20:28:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511411285; cv=none; d=google.com; s=arc-20160816; b=jkujaV3wvz9tHXCdKwDTB45GZ7svj78KpRNVsFdXur3tli8jScgHzx2aidj7a7kpjy Ox82sO47p4i75vK2BceEN0AUOBYsTVQ2Ll7xJDzX38pY6v25FMcpYW7RfrPoto+s30Rp KfMWQxsmU9ZlVGze8VmcaZLYl/YFpaN7v74wib3lwzoqW0HljQBXMZtnWBv639eo4GEX 1wZacO9EElfBb24UomNvtHHOeK1Hw6hIMKJoCL9Q6MWGEoIsZgpSjvF97mJfvVawsAe2 qo7aerE9mzbaPWkf54exRJwFxliae1dc6423l/5H/v/uO5oe4WG9jDiWa3TL3BxID1Wd 4PBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=AWVIar9qOXfFziGAc8pfXC28q7apxIwsSS9N1NGTi6E=; b=CkQKIKd470gmUWZRIIpmNpQLbPv63gkyhYFNQQWTwWRJcmh6o8Zf5w2Ge0MePTn4z6 MC4f6JU9uuX+QLpARX4Gpsiciy4pAiHgo7tmoJYmsn24KIV8ZRRXpX4dNeASTn7RvM43 j0Eiv4ft6lftXKW7zcprNGw1t6k+zqDCt3kduuxCoa9TKntQs3MLHdV4eM47jwrjsmy/ SBU01ci5KMaorsuZqD9jIlUGauiSkPD5xbRRN1aCrHVYyTcyRMoWPQrAhxpIEOAxrAnX 1EpeGpGFm5UELF1RLRqULNSnkauT4OVY04OvV9Fhjawy7MUKw27wDNgKs383is3i3DqV DbQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gateworks-com.20150623.gappssmtp.com header.s=20150623 header.b=fiBgDg7a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si14339169pgd.769.2017.11.22.20.27.54; Wed, 22 Nov 2017 20:28:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gateworks-com.20150623.gappssmtp.com header.s=20150623 header.b=fiBgDg7a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752380AbdKWE1R (ORCPT + 77 others); Wed, 22 Nov 2017 23:27:17 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:43594 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752110AbdKWE1O (ORCPT ); Wed, 22 Nov 2017 23:27:14 -0500 Received: by mail-wm0-f49.google.com with SMTP id x63so14117909wmf.2 for ; Wed, 22 Nov 2017 20:27:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gateworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=AWVIar9qOXfFziGAc8pfXC28q7apxIwsSS9N1NGTi6E=; b=fiBgDg7ae1gIyloTIIYh1d4BnP/kTsplYFzdQaWjZ2unYFJtomfhfHxteO7f1DHwZs DL/qwJvd/+Uh3jeyFZ2iX0McLNuTIUzdjPzWRysOVwAJAO7qpPfHZtpA+hm6Qjv8g/HF PFQRrgKLsZbRVAhh3L6mHko6GcoMh6lJj6s/1cdyiAL2DvthXo+B19o1bZyTPUbl/I4q luVqLxXTRELiw65M5omxDYxodMGaf/KiY/ERELet8zyHOWNfSycJx96gqgbeodZb05hp AOBli4AmUF/Co+ZoPtMtjITuqJNm92A75o597ClTt7DKoIqxaOzBwlIiSbUea5c85p3O hcrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=AWVIar9qOXfFziGAc8pfXC28q7apxIwsSS9N1NGTi6E=; b=P9FGV3TYEIp36XBeGA/a57fFDi6Elv7bUaZVame3YClTzwl/TqadY8CoKFFQdVAIYK 5nZzpF4+IYMn84RAYIWisSv5JggoPIJdEpKtvKstPMhX7mJ42FmSFdlZFueESP9laZzK /QWEHGWVTwi78nLzYYBBPvimc84D4TRGHIHJDegzDdMsH/b0s68H6YMpFWKT8EDATFz0 Ytzm7dh9PlEXXyZj5iICdFkT2aF9cKbP3MXX6wCSYMoe3IqxPx/ND2FzcdPgRiuAH4KT GREJ6nNHXTTNLP8k/l3GmAsV0vV5BfC8hhUrgMEmaL2DEFgwnO3Jv5q8vlbQuxitR0rK ViIg== X-Gm-Message-State: AJaThX4Ktf0pSOM6cWM/cC8SS//yfJrejwpwHdyXkj6Hu0hSnyFLinBH IQYfTtNQTtIkL2NmdIDJbshwHGbui/K9GkFjOwo9iQ== X-Received: by 10.28.183.132 with SMTP id h126mr5779950wmf.76.1511411233405; Wed, 22 Nov 2017 20:27:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.16.198 with HTTP; Wed, 22 Nov 2017 20:27:12 -0800 (PST) In-Reply-To: <4048cb21-c65c-6282-a1d7-81ad9a0d7cfa@xs4all.nl> References: <1510253136-14153-1-git-send-email-tharvey@gateworks.com> <1510253136-14153-4-git-send-email-tharvey@gateworks.com> <4048cb21-c65c-6282-a1d7-81ad9a0d7cfa@xs4all.nl> From: Tim Harvey Date: Wed, 22 Nov 2017 20:27:12 -0800 Message-ID: Subject: Re: [PATCH 3/5] media: i2c: Add TDA1997x HDMI receiver driver To: Hans Verkuil Cc: linux-media , alsa-devel@alsa-project.org, "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Shawn Guo , Steve Longerbeam , Philipp Zabel , Hans Verkuil , Mauro Carvalho Chehab Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 20, 2017 at 7:39 AM, Hans Verkuil wrote: > Hi Tim, > > Some more review comments: > > On 11/09/2017 07:45 PM, Tim Harvey wrote: >> Add support for the TDA1997x HDMI receivers. >> + */ >> +struct color_matrix_coefs { >> + const char *name; >> + /* Input offsets */ >> + s16 offint1; >> + s16 offint2; >> + s16 offint3; >> + /* Coeficients */ >> + s16 p11coef; >> + s16 p12coef; >> + s16 p13coef; >> + s16 p21coef; >> + s16 p22coef; >> + s16 p23coef; >> + s16 p31coef; >> + s16 p32coef; >> + s16 p33coef; >> + /* Output offsets */ >> + s16 offout1; >> + s16 offout2; >> + s16 offout3; >> +}; >> + >> +enum { >> + ITU709_RGBLIMITED, >> + ITU709_RGBFULL, >> + ITU601_RGBLIMITED, >> + ITU601_RGBFULL, >> + RGBLIMITED_RGBFULL, >> + RGBLIMITED_ITU601, >> + RGBFULL_ITU601, > > This can't be right. >ITU709_RGBLIMITED > You have these conversions: > > ITU709_RGBFULL > ITU601_RGBFULL > RGBLIMITED_RGBFULL > RGBLIMITED_ITU601 > RGBFULL_ITU601 > RGBLIMITED_ITU709 > RGBFULL_ITU709 > > I.e. on the HDMI receiver side you can receive RGB full/limited or ITU601/709. > On the output side you have RGB full or ITU601/709. > > So something like ITU709_RGBLIMITED makes no sense. > I misunderstood the V4L2_CID_DV_RX_RGB_RANGE thinking that it allowed you to configure the output range. If output to the SoC is only ever full quant range for RGB then I can drop the ITU709_RGBLIMITED/ITU601_RGBLIMITED conversions. However, If the output is YUV how do I know if I need to convert to ITU709 or ITU601 and what are my conversion matrices for RGBLIMITED_ITU709/RGBFULL_ITU709? Sorry for all the questions, the colorspace/colorimetry options confuse the heck out of me. >> +}; >> + >> + >> +/* parse an infoframe and do some sanity checks on it */ >> +static unsigned int >> +tda1997x_parse_infoframe(struct tda1997x_state *state, u16 addr) >> +{ >> + struct v4l2_subdev *sd = &state->sd; >> + union hdmi_infoframe frame; >> + u8 buffer[40]; >> + u8 reg; >> + int len, err; >> + >> + /* read data */ >> + len = io_readn(sd, addr, sizeof(buffer), buffer); >> + err = hdmi_infoframe_unpack(&frame, buffer); >> + if (err) { >> + v4l_err(state->client, >> + "failed parsing %d byte infoframe: 0x%04x/0x%02x\n", >> + len, addr, buffer[0]); >> + return err; >> + } >> + hdmi_infoframe_log(KERN_INFO, &state->client->dev, &frame); >> + switch (frame.any.type) { >> + /* Audio InfoFrame: see HDMI spec 8.2.2 */ >> + case HDMI_INFOFRAME_TYPE_AUDIO: >> + /* sample rate */ >> + switch (frame.audio.sample_frequency) { >> + case HDMI_AUDIO_SAMPLE_FREQUENCY_32000: >> + state->audio_samplerate = 32000; >> + break; >> + case HDMI_AUDIO_SAMPLE_FREQUENCY_44100: >> + state->audio_samplerate = 44100; >> + break; >> + case HDMI_AUDIO_SAMPLE_FREQUENCY_48000: >> + state->audio_samplerate = 48000; >> + break; >> + case HDMI_AUDIO_SAMPLE_FREQUENCY_88200: >> + state->audio_samplerate = 88200; >> + break; >> + case HDMI_AUDIO_SAMPLE_FREQUENCY_96000: >> + state->audio_samplerate = 96000; >> + break; >> + case HDMI_AUDIO_SAMPLE_FREQUENCY_176400: >> + state->audio_samplerate = 176400; >> + break; >> + case HDMI_AUDIO_SAMPLE_FREQUENCY_192000: >> + state->audio_samplerate = 192000; >> + break; >> + default: >> + case HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM: >> + break; >> + } >> + >> + /* sample size */ >> + switch (frame.audio.sample_size) { >> + case HDMI_AUDIO_SAMPLE_SIZE_16: >> + state->audio_samplesize = 16; >> + break; >> + case HDMI_AUDIO_SAMPLE_SIZE_20: >> + state->audio_samplesize = 20; >> + break; >> + case HDMI_AUDIO_SAMPLE_SIZE_24: >> + state->audio_samplesize = 24; >> + break; >> + case HDMI_AUDIO_SAMPLE_SIZE_STREAM: >> + default: >> + break; >> + } >> + >> + /* Channel Count */ >> + state->audio_channels = frame.audio.channels; >> + if (frame.audio.channel_allocation && >> + frame.audio.channel_allocation != state->audio_ch_alloc) { >> + /* use the channel assignment from the infoframe */ >> + state->audio_ch_alloc = frame.audio.channel_allocation; >> + tda1997x_configure_audout(sd, state->audio_ch_alloc); >> + /* reset the audio FIFO */ >> + tda1997x_hdmi_info_reset(sd, RESET_AUDIO, false); >> + } >> + break; >> + >> + /* Auxiliary Video information (AVI) InfoFrame: see HDMI spec 8.2.1 */ >> + case HDMI_INFOFRAME_TYPE_AVI: >> + state->colorspace = frame.avi.colorspace; >> + state->colorimetry = frame.avi.colorimetry; >> + state->range = frame.avi.quantization_range; > > This should be ignored if it is overridden by the RGB Quantization Range > control, or am I missing something? > Ok. Sounds like I should only use the range from the infoframe if range == V4L2_DV_RGB_RANGE_AUTO: /* Quantization Range */ if (state->range == V4L2_DV_RGB_RANGE_AUTO) state->range = frame.avi.quantization_range; if (state->range == HDMI_QUANTIZATION_RANGE_DEFAULT) { if (frame.avi.video_code <= 1) state->range = HDMI_QUANTIZATION_RANGE_FULL; else state->range = HDMI_QUANTIZATION_RANGE_LIMITED; } >> + state->content = frame.avi.content_type; >> + /* >> + * If colorimetry not specified, conversion depends on res type: >> + * - SDTV: ITU601 for SD (480/576/240/288 line resolution) >> + * - HDTV: ITU709 for HD (720/1080 line resolution) >> + * - PC: sRGB >> + * see HDMI specification section 6.7 >> + */ >> + if ((state->colorspace == HDMI_COLORSPACE_YUV422 || >> + state->colorspace == HDMI_COLORSPACE_YUV444) && >> + (state->colorimetry == HDMI_COLORIMETRY_EXTENDED || >> + state->colorimetry == HDMI_COLORIMETRY_NONE)) { >> + switch (state->timings.bt.height) { >> + case 480: >> + case 576: >> + case 240: >> + case 288: >> + state->colorimetry = HDMI_COLORIMETRY_ITU_601; >> + break; >> + case 720: >> + case 1080: >> + state->colorimetry = HDMI_COLORIMETRY_ITU_709; >> + break; >> + default: >> + state->colorimetry = HDMI_COLORIMETRY_NONE; >> + break; >> + } >> + } >> + /* if range not specified */ >> + if (state->range == HDMI_QUANTIZATION_RANGE_DEFAULT) { >> + if (frame.avi.video_code == 0) > > This should be: > > if (frame.avi.video_code <= 1) > > VIC code 1 (VGA) is also full range. It's an exception to the rule. ok Thanks, Tim From 1584600129928274175@xxx Mon Nov 20 15:40:45 +0000 2017 X-GM-THRID: 1583615313022071316 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread