From patchwork Mon Feb 12 13:13:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Anikiel?= X-Patchwork-Id: 199791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2431051dyd; Mon, 12 Feb 2024 05:37:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXrFoY4F17lnPb8NGjT4WofE7nib3RMk0WRk+G6PzOgJG6AKLnCQmM90NLNqO+qteaao4XrjvQC+fl2vjKm/LTt4xDbTw== X-Google-Smtp-Source: AGHT+IHMR9lGg9RKqJnY1gzQFZlrN++3HAllHod8dcSYzeO8AL5lblS2cxFJm/KBOj8momFvyJVN X-Received: by 2002:a05:6358:7606:b0:179:24ae:25dd with SMTP id r6-20020a056358760600b0017924ae25ddmr7377239rwg.25.1707745064589; Mon, 12 Feb 2024 05:37:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707745064; cv=pass; d=google.com; s=arc-20160816; b=JLu1ka1Zpc7Ix539ZwKp69zG+cQYlN53l2FuPKK4j4ILZvHBfFHfUiJAHsP4CbUgJK gf399/Pd2df6R8ech7CX6MoCjG9UVxlIrV1VqRk64vM1dWCtuitBRJxSSkT1O2eHQvYN BdcF9Oz93/IJrjjOH+wI8xzcyrrR5NgUW+UIxKRkaXFo3m6mttzyGIS0K8SZ+k4fZncb 0bzemliTyQz+PnhRLVJc3COdiecuWV/sBT6eKtQZNLy4QpcgGTHFATF/5uXeRu2cP/GS DA7/8dy/tuExj0R9cwCBqeaASUluolJRYG9XqWmIkKljuHd51o3Ub7hasKQkWkf78YCo FrtA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=9j4Lx9tyhvatf/UB1EXBEYAcw6HSL3npB5akS3xX/6Q=; fh=EfejrgBqWScisIlPJJ0xyOUPvZu/IGyQtZ9AHDxqzOQ=; b=Uts81KmxTG0J5RP83Kv+gZuTVNtjI0qtaRBaF64VE3tDIx8/mJSsMzogamtyABsaQV OUmXFeuCY2x18puoACx4IxCXxcBl1pELxDf/RMLsaf9t1ex3rPADcXPTO8/fPmP80Rt1 gfbM+G/qVNO+2v8oI0hNbdFGIaerYhb0byV8aRN6QN08eNxIj5E6ll9PnvsDUGRis7GI VO80QtVHlBgzEQL5ulAR89wGPs9oNsPDzk9xm+SfnPTbCirwZHRAJFWABekc6qpkeNrn jdOvYJ5L3o8PLFKY779AXmxb+7DWZxWGUYFL9ZiqSeahvQCAJUayld525UOR49t9j5h3 7+fg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WrFfZpJG; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61634-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61634-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCVVrFw/mo59EtZ9snm/LwAfUi6pMQCtrjIuE9FOTgz4731ZcBay0V8HRBxdx7Bg+fMD0iflD9VTDGAFTi/dHz0tmtBzfg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b17-20020a637151000000b005dc6d16be5csi256000pgn.439.2024.02.12.05.37.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:37:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61634-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WrFfZpJG; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61634-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61634-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4DEB4B24482 for ; Mon, 12 Feb 2024 13:20:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4CD93FE4B; Mon, 12 Feb 2024 13:14:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WrFfZpJG" Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 841573FB3D for ; Mon, 12 Feb 2024 13:14:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743662; cv=none; b=IMsaRLWiyCKva1Pp8j7p6XcmeVc5MsmveYBfiXEedDyIQCxzrZI3yYY6lK2czLUe656XOSBNfHpyzAwz6zXyNBBTIvEMrykqfq6y9nyel+vDBsFOlNpY/hhpCYBy1qIIVPd0ClYNNWT6Y/2Y9LrHhU1xNK9YnAUC3iSsRqvhlIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743662; c=relaxed/simple; bh=44gbYdkUjK/VyqM35SbTTnBnkkPFnzVy/nqzzk4zJBQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=n0CcTGTeYE6LguQfbgo4oh55LX1V75ixaijY69DCI8pZWLq2QjFPtIXd6aeK/2mfp28klKAKCEan3IUC9egKp08nl0yGeNpieqBa48d8MOEKMi9DOmI4h/ZjGvDWxwTahhjcEWwdeqv48V6ni7EP7eWMlYHbdlCEhUjlGmV4uig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=WrFfZpJG; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-410422e8cd1so19338285e9.3 for ; Mon, 12 Feb 2024 05:14:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707743659; x=1708348459; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=9j4Lx9tyhvatf/UB1EXBEYAcw6HSL3npB5akS3xX/6Q=; b=WrFfZpJGl2UP9WRLyFy5TzfKZJQL/Iinb1N4BS/Akwt0WaMIn9bj4BOC8du7cIqMlT /roF1YB2ohNNL4JfD+IXbkvPSm50oE9zizW5z0NybVK2zBtW60FMpAvTxaHTsyB3IYm4 UNjteobMKQz6vxVAk9u4qALqgy0lBR9p6az1ZxfBXRbjIR3J5wdVutk+j1ILTcx5HyzT fAIA6ozzI6f5ok7wN130WSefrP8vmqHClp+A/s31VzK7BQk8cW8E6rgWFtAqBhbeenEY BTe8nk8TfQ70LIh8xOAsoxYhu06JEbXrZ1NOp5VEkHJPqIifeBNBiwatQmYt5FMoA4n8 Kruw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707743659; x=1708348459; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=9j4Lx9tyhvatf/UB1EXBEYAcw6HSL3npB5akS3xX/6Q=; b=DdRzcGUwiJs81EUjQy23D0nMj7noGvigF7jHrds6KVU/4THgCB8Y7l6AFlNkzkzBsE u/zYanXDkhCi47AcS0V5lJlG+Cvj5TeOWPAWcdPRND7eBls9orBGVMhsmZfDDdCt/SDN 2smEglawM6uFnD1MbBcSzMz8WJcwdqhTkNQ8LHcYi1ljY7+9y74+XHWW6Hqi5r9EGVAS WJ2E/DCQHjDMlcnCi4xQg1J/YdPsk5Nh0Au550kqiSEpgZvJyrbpUhzJL15wWOtdS6Vo Qp5fv1wukGM0RUlrixAAz14p4nPKv9W1733z4zp/uE+xeD1QfvLM7xhHUX3nymXLZjpb qnAA== X-Forwarded-Encrypted: i=1; AJvYcCUY//ccPVgPJWmJO1yZLolGcAO29JsFwoC2xX52n5CbipeKbrfKfZXeslXX+TrSdeQ/BG0pDZ1CZJKW2/ShtEdJa0AnMn1HKxv8wPBx X-Gm-Message-State: AOJu0YxMm3sL2G4lkrlsX8OKCZ2JIsvDfvSlWenYRCrp2Dm7+LSTIwtL zFcvQZDU3ws2ydP53yKm4JrwU6yDDwvSCehVtDBXoI3VCg+LmPvfWf68zRdT6APBsHbOEeyU02H Nyhqa8g0XvQ== X-Received: from szatan.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:2d83]) (user=panikiel job=sendgmr) by 2002:a7b:c2b2:0:b0:410:c0e6:c975 with SMTP id c18-20020a7bc2b2000000b00410c0e6c975mr12370wmk.4.1707743658932; Mon, 12 Feb 2024 05:14:18 -0800 (PST) Date: Mon, 12 Feb 2024 13:13:15 +0000 In-Reply-To: <20240212131323.2162161-1-panikiel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240212131323.2162161-1-panikiel@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240212131323.2162161-2-panikiel@google.com> Subject: [PATCH 1/9] media: v4l2-subdev: Add a pad variant of .query_dv_timings() From: " =?utf-8?q?Pawe=C5=82_Anikiel?= " To: airlied@gmail.com, akpm@linux-foundation.org, conor+dt@kernel.org, daniel@ffwll.ch, dinguyen@kernel.org, hverkuil-cisco@xs4all.nl, krzysztof.kozlowski+dt@linaro.org, maarten.lankhorst@linux.intel.com, mchehab@kernel.org, mripard@kernel.org, robh+dt@kernel.org, tzimmermann@suse.de Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, chromeos-krk-upstreaming@google.com, ribalda@chromium.org, " =?utf-8?q?Pawe?= =?utf-8?q?=C5=82_Anikiel?= " X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790700488958577227 X-GMAIL-MSGID: 1790700488958577227 Currently, .query_dv_timings() is defined as a video callback without a pad argument. This is a problem if the subdevice can have different dv timings for each pad (e.g. a DisplayPort receiver with multiple virtual channels). To solve this, add a pad variant of this callback which includes the pad number as an argument. Signed-off-by: Paweł Anikiel --- drivers/media/v4l2-core/v4l2-subdev.c | 11 +++++++++++ include/media/v4l2-subdev.h | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 4c6198c48dd6..11f865dd19b4 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -389,6 +389,16 @@ static int call_enum_dv_timings(struct v4l2_subdev *sd, sd->ops->pad->enum_dv_timings(sd, dvt); } +static int call_query_dv_timings(struct v4l2_subdev *sd, unsigned int pad, + struct v4l2_dv_timings *timings) +{ + if (!timings) + return -EINVAL; + + return check_pad(sd, pad) ? : + sd->ops->pad->query_dv_timings(sd, pad, timings); +} + static int call_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad, struct v4l2_mbus_config *config) { @@ -489,6 +499,7 @@ static const struct v4l2_subdev_pad_ops v4l2_subdev_call_pad_wrappers = { .set_edid = call_set_edid, .dv_timings_cap = call_dv_timings_cap, .enum_dv_timings = call_enum_dv_timings, + .query_dv_timings = call_query_dv_timings, .get_frame_desc = call_get_frame_desc, .get_mbus_config = call_get_mbus_config, }; diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index a9e6b8146279..dc8963fa5a06 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -797,6 +797,9 @@ struct v4l2_subdev_state { * @enum_dv_timings: callback for VIDIOC_SUBDEV_ENUM_DV_TIMINGS() ioctl handler * code. * + * @query_dv_timings: same as query_dv_timings() from v4l2_subdev_video_ops, + * but with additional pad argument. + * * @link_validate: used by the media controller code to check if the links * that belongs to a pipeline can be used for stream. * @@ -868,6 +871,8 @@ struct v4l2_subdev_pad_ops { struct v4l2_dv_timings_cap *cap); int (*enum_dv_timings)(struct v4l2_subdev *sd, struct v4l2_enum_dv_timings *timings); + int (*query_dv_timings)(struct v4l2_subdev *sd, unsigned int pad, + struct v4l2_dv_timings *timings); #ifdef CONFIG_MEDIA_CONTROLLER int (*link_validate)(struct v4l2_subdev *sd, struct media_link *link, struct v4l2_subdev_format *source_fmt, From patchwork Mon Feb 12 13:13:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Anikiel?= X-Patchwork-Id: 199765 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2422954dyd; Mon, 12 Feb 2024 05:23:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHAv5Pqcx+HDSIq7nPD9WoaFux6wsZX/Yruid7Wgt06p6YfPir1VBG4ZJ7jCRgaqicaN9v3 X-Received: by 2002:a05:6214:300c:b0:68c:86b4:bc67 with SMTP id ke12-20020a056214300c00b0068c86b4bc67mr9456437qvb.7.1707744188711; Mon, 12 Feb 2024 05:23:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707744188; cv=pass; d=google.com; s=arc-20160816; b=tiM9Y6hlv54ytbACQdkBOVIRVqVbnwY3hzhqqmVygHdq0H4eaEOY6zzPHGAxg5JXeP iGPXQH61AlEyqkm7ahExzrqZi5wZpwivIYSQHZwSbe02O8VndOfh67xcNjhWbWawH0YO 40LtLNEA4dmhziYIaVrDjgnFjqAVeSkNka4vDfGyz20S7rZGhlDo+l1afIjZpKXdJJsS vdoCKF7LwnJ42ZsKKFDDFoJvawoTaH1dRCsXDnlrDBHwOR/aFGzMo5whhVGC6eWx0duu QjWtRvkuo0qmOEEqgoIwMK2gjqd9e1Yb6+IPg7P+JstJql+leEFyS57FDe+kVPPJ/pTz B2lw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=7bYpEjwrp4hjFjtRkB0M//Ln9ckhLP4bN64T2e35RCA=; fh=ZeBHQwE1DoPM5tPak2Rnr/MH1+9J2zcQE0LFE0qT6qk=; b=1LGt6ftpwDA2Ox55ArHld55N0FcmI75TyRYe8cL43wvGlbRSdcBoFin4P7nRR7OTwz 6DVs0TsjvDqDR38ECnQ0A8o0i2qak4Eqig+GZPYvaKiDsFuMaf6hglyZDWabsvt1yGeS hHXbSuWtJ9rAEaE//x3RBusa+M7MWx+DL5ZG1d3Zpl27VtWJSO/hT5JhvPsAu2u1x+EX f1u4XFOJsC1CqWFuWmzCMo9hoGLr6N/JZj6aiCp5+de0fmqB2ktdXsNtrOs64b72LPva 5K4DHHUFxPKw9+6ba4LY++Q+UFya/ncjGf/f0DmGRgWRdk7/BQ36P0KkblVsMUeiMSLD C1hw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=BBpr3axM; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61637-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61637-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCVBZMl2PVZgm+X+cQE1aEZz9F8IpptN6v6+jSfVg9VTbt5Lv4HMm4mT9IdYaAA5Q5g6pf9wQuhXxYK9riu+rHd0y9mpcQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id kk4-20020a056214508400b0068c3d2d61f1si353146qvb.120.2024.02.12.05.23.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:23:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61637-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=BBpr3axM; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61637-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61637-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 703241C20C24 for ; Mon, 12 Feb 2024 13:23:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5253D4C62B; Mon, 12 Feb 2024 13:14:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BBpr3axM" Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5C9B40BE6 for ; Mon, 12 Feb 2024 13:14:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743666; cv=none; b=FL4rkagM1ahfxSaohDtM4/yqjgVh8yuQpshzvPXcixFc6eEvHtmXlOjBX8gdhCNxXelzuzRRFHo20sBbMof6n/HsqEVegMqrvbKhGQwevKB9fTFA84FQGeXoGBGeF1p6/jLcrpVmg7WtQ6igPijvsltDa9KRsoDywF6B8WLuowc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743666; c=relaxed/simple; bh=Bdut/0GlvZDtHk8g55fNLfNN6hPIiddZiIzQE551eZU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=QH5DrYpDR8UG4ZovHFxVaqawVkkwQw0z07BHJpFsGFmTnYlx6iMkmn8opVqvUsnf2lhN16Lzm57ZB+/SNdK7MZ+SDhpwgznbo5lMrZknBrhLTc8rTn2i05EG9S8gV6bkjWeXFZxKQk7ioS3WOe1vvz+NwAJmqVTmDPyXF1JG9Gg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=BBpr3axM; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-410b8e90b4fso8273315e9.2 for ; Mon, 12 Feb 2024 05:14:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707743661; x=1708348461; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=7bYpEjwrp4hjFjtRkB0M//Ln9ckhLP4bN64T2e35RCA=; b=BBpr3axMlwoNRhcwLcwuqpGHx0/NFLNcPJ5bb5mWezl9M5nMmtfD3EKncSEWKfIH5H Ib2gl+5qDW89FHJCkZmFFHZvmM49FTMRl1erUuOgRR16jFAC2GwmzP1R44WsVC7Zl/uB iPvjRp6gNQIbzXqKm1i2yDZKo6JKwUE6MhkwTNMgw1C3WwJkYSUji5mlUOFY3vCwFwtf avZDm82UGbVzADkarRmQe2jrSG+6mqsZaUegXSxQHGVJsyVyiK/Jo4IWWfb+WOdBvPib nSXF5n96Tl2XCv8QUDMkhPqXV6rvxQSnf4BKtWkLV0a4ePz95xT2hzZv2TLBAckldn5A H2sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707743661; x=1708348461; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=7bYpEjwrp4hjFjtRkB0M//Ln9ckhLP4bN64T2e35RCA=; b=gZww36ImLxL77MTLS1tBHiQ6KtNKhtr9xFoy+SvbjO36CW1tLcsZix6zuarlSdbeVB RikBybLhQNpkp7qep1g8N8p7hM7wF5QvmY8zNyvv5fZT08be8h0H/76QfjggFU65qs9H u4k0DSz5k8zE1WI8jm/9AQzzNGv+fzLaNHf7oaEPAS28dGPp4TXrFy+yEjNvYUD9HZog Iks62vDs8Cj8udPZ64P++1WkVdeGe5fezWw7kohbKsmN4MDtrTgMlfqLucoB6V2ZFGYh 2oymo1+dj4FKXJOGK2BsQGlCWKGGW5wWHyo1MHBQY/U5gH1gSI4zPH+H5jWgSmPxDZkx uMLA== X-Gm-Message-State: AOJu0YxFoDr3TrGh/92r55mlI0LQ+0LcOD4bUUNoHp3cI4wQQZEad4JB 9zF1HjpfS8S3vsidxhkEzm3n4m8RRt4EyiAX2tSrPbL1xgsBLE9ptyLaUU42l/GOWzohxUQ6Jk9 ftXGR+wr9uA== X-Received: from szatan.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:2d83]) (user=panikiel job=sendgmr) by 2002:a05:600c:4e01:b0:410:ebbf:bb8c with SMTP id b1-20020a05600c4e0100b00410ebbfbb8cmr7137wmq.2.1707743661201; Mon, 12 Feb 2024 05:14:21 -0800 (PST) Date: Mon, 12 Feb 2024 13:13:16 +0000 In-Reply-To: <20240212131323.2162161-1-panikiel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240212131323.2162161-1-panikiel@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240212131323.2162161-3-panikiel@google.com> Subject: [PATCH 2/9] media: Add Chameleon v3 framebuffer driver From: " =?utf-8?q?Pawe=C5=82_Anikiel?= " To: airlied@gmail.com, akpm@linux-foundation.org, conor+dt@kernel.org, daniel@ffwll.ch, dinguyen@kernel.org, hverkuil-cisco@xs4all.nl, krzysztof.kozlowski+dt@linaro.org, maarten.lankhorst@linux.intel.com, mchehab@kernel.org, mripard@kernel.org, robh+dt@kernel.org, tzimmermann@suse.de Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, chromeos-krk-upstreaming@google.com, ribalda@chromium.org, " =?utf-8?q?Pawe?= =?utf-8?q?=C5=82_Anikiel?= " X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790699570294652620 X-GMAIL-MSGID: 1790699570294652620 Add v4l2 driver for the Google Chameleon v3 framebuffer device. Signed-off-by: Paweł Anikiel --- drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/google/Kconfig | 3 + drivers/media/platform/google/Makefile | 2 + .../media/platform/google/chameleonv3/Kconfig | 13 + .../platform/google/chameleonv3/Makefile | 3 + .../platform/google/chameleonv3/chv3-fb.c | 897 ++++++++++++++++++ 7 files changed, 920 insertions(+) create mode 100644 drivers/media/platform/google/Kconfig create mode 100644 drivers/media/platform/google/Makefile create mode 100644 drivers/media/platform/google/chameleonv3/Kconfig create mode 100644 drivers/media/platform/google/chameleonv3/Makefile create mode 100644 drivers/media/platform/google/chameleonv3/chv3-fb.c diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index 91e54215de3a..b82f7b142b85 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig @@ -69,6 +69,7 @@ source "drivers/media/platform/aspeed/Kconfig" source "drivers/media/platform/atmel/Kconfig" source "drivers/media/platform/cadence/Kconfig" source "drivers/media/platform/chips-media/Kconfig" +source "drivers/media/platform/google/Kconfig" source "drivers/media/platform/intel/Kconfig" source "drivers/media/platform/marvell/Kconfig" source "drivers/media/platform/mediatek/Kconfig" diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile index 3296ec1ebe16..f7067eb05f76 100644 --- a/drivers/media/platform/Makefile +++ b/drivers/media/platform/Makefile @@ -12,6 +12,7 @@ obj-y += aspeed/ obj-y += atmel/ obj-y += cadence/ obj-y += chips-media/ +obj-y += google/ obj-y += intel/ obj-y += marvell/ obj-y += mediatek/ diff --git a/drivers/media/platform/google/Kconfig b/drivers/media/platform/google/Kconfig new file mode 100644 index 000000000000..2a5f01034c11 --- /dev/null +++ b/drivers/media/platform/google/Kconfig @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +source "drivers/media/platform/google/chameleonv3/Kconfig" diff --git a/drivers/media/platform/google/Makefile b/drivers/media/platform/google/Makefile new file mode 100644 index 000000000000..c971a09faeb4 --- /dev/null +++ b/drivers/media/platform/google/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-y += chameleonv3/ diff --git a/drivers/media/platform/google/chameleonv3/Kconfig b/drivers/media/platform/google/chameleonv3/Kconfig new file mode 100644 index 000000000000..76d0383a8589 --- /dev/null +++ b/drivers/media/platform/google/chameleonv3/Kconfig @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config VIDEO_CHV3_FB + tristate "Google Chameleon v3 framebuffer video driver" + depends on V4L_PLATFORM_DRIVERS + depends on VIDEO_DEV + select VIDEOBUF2_DMA_CONTIG + select V4L2_FWNODE + help + v4l2 driver for the video interface present on the Google + Chameleon v3. The Chameleon v3 uses the framebuffer IP core + to take the video signal from different sources and directly + write frames into memory. diff --git a/drivers/media/platform/google/chameleonv3/Makefile b/drivers/media/platform/google/chameleonv3/Makefile new file mode 100644 index 000000000000..d63727148688 --- /dev/null +++ b/drivers/media/platform/google/chameleonv3/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_VIDEO_CHV3_FB) += chv3-fb.o diff --git a/drivers/media/platform/google/chameleonv3/chv3-fb.c b/drivers/media/platform/google/chameleonv3/chv3-fb.c new file mode 100644 index 000000000000..1bcd7410a743 --- /dev/null +++ b/drivers/media/platform/google/chameleonv3/chv3-fb.c @@ -0,0 +1,897 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2023-2024 Google LLC. + * Author: Paweł Anikiel + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEVICE_NAME "chv3-fb" + +/* + * The device is expected to report some format even if there's currently no + * active video stream. In such case we default to 1080p. + */ +#define DEFAULT_WIDTH 1920 +#define DEFAULT_HEIGHT 1080 + +#define FB_EN 0x00 +#define FB_EN_BIT BIT(0) +#define FB_HEIGHT 0x04 +#define FB_WIDTH 0x08 +#define FB_BUFFERA 0x0c +#define FB_BUFFERB 0x10 +#define FB_BUFFERSIZE 0x14 +#define FB_RESET 0x18 +#define FB_RESET_BIT BIT(0) +#define FB_ERRORSTATUS 0x1c +#define FB_IOCOLOR 0x20 +#define FB_DATARATE 0x24 +#define FB_DATARATE_SINGLE 0x0 +#define FB_DATARATE_DOUBLE 0x1 +#define FB_PIXELMODE 0x28 +#define FB_PIXELMODE_SINGLE 0x0 +#define FB_PIXELMODE_DOUBLE 0x1 +#define FB_SYNCPOLARITY 0x2c +#define FB_DMAFORMAT 0x30 +#define FB_DMAFORMAT_8BPC 0x0 +#define FB_DMAFORMAT_10BPC_UPPER 0x1 +#define FB_DMAFORMAT_10BPC_LOWER 0x2 +#define FB_DMAFORMAT_12BPC_UPPER 0x3 +#define FB_DMAFORMAT_12BPC_LOWER 0x4 +#define FB_DMAFORMAT_16BPC 0x5 +#define FB_DMAFORMAT_RAW 0x6 +#define FB_DMAFORMAT_8BPC_LEGACY 0x7 +#define FB_VERSION 0x34 +#define FB_VERSION_CURRENT 0xc0fb0001 + +#define FB_IRQ_MASK 0x8 +#define FB_IRQ_CLR 0xc +#define FB_IRQ_ALL 0xf +#define FB_IRQ_BUFF0 BIT(0) +#define FB_IRQ_BUFF1 BIT(1) +#define FB_IRQ_RESOLUTION BIT(2) +#define FB_IRQ_ERROR BIT(3) + +struct chv3_fb { + struct device *dev; + void __iomem *iobase; + void __iomem *iobase_irq; + + struct v4l2_device v4l2_dev; + struct vb2_queue queue; + struct video_device vdev; + struct v4l2_pix_format pix_fmt; + struct v4l2_dv_timings timings; + + struct v4l2_async_notifier notifier; + struct v4l2_subdev *subdev; + int subdev_source_pad; + + u32 sequence; + bool writing_to_a; + + struct list_head bufs; + spinlock_t bufs_lock; + + struct mutex fb_lock; +}; + +struct chv3_fb_buffer { + struct vb2_v4l2_buffer vb; + struct list_head link; +}; + +static void chv3_fb_set_format_resolution(struct chv3_fb *fb, u32 width, u32 height) +{ + u32 bytes_per_pixel; + + if (fb->pix_fmt.pixelformat == V4L2_PIX_FMT_RGB24) + bytes_per_pixel = 3; + else + bytes_per_pixel = 4; + + fb->pix_fmt.width = width; + fb->pix_fmt.height = height; + fb->pix_fmt.bytesperline = width * bytes_per_pixel; + fb->pix_fmt.sizeimage = fb->pix_fmt.bytesperline * height; +} + +/* + * The video interface has hardware counters which expose the width and + * height of the current video stream. It can't reliably detect if the stream + * is present or not, so this is only used as a fallback in the case where + * we don't have access to the receiver hardware. + */ +static int chv3_fb_query_dv_timings_fallback(struct chv3_fb *fb, + struct v4l2_dv_timings *timings) +{ + u32 width, height; + + width = readl(fb->iobase + FB_WIDTH); + height = readl(fb->iobase + FB_HEIGHT); + if (width == 0 || height == 0) + return -ENOLINK; + + memset(timings, 0, sizeof(*timings)); + timings->type = V4L2_DV_BT_656_1120; + timings->bt.width = width; + timings->bt.height = height; + + return 0; +} + +static int chv3_fb_query_dv_timings(struct chv3_fb *fb, struct v4l2_dv_timings *timings) +{ + if (fb->subdev) { + return v4l2_subdev_call(fb->subdev, pad, query_dv_timings, + fb->subdev_source_pad, timings); + } else { + return chv3_fb_query_dv_timings_fallback(fb, timings); + } +} + +static const struct v4l2_dv_timings_cap chv3_fb_fallback_dv_timings_cap = { + .type = V4L2_DV_BT_656_1120, + .bt = { + .min_width = 0, + .max_width = 65535, + .min_height = 0, + .max_height = 65535, + .min_pixelclock = 0, + .max_pixelclock = 2147483647, + .standards = V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT | + V4L2_DV_BT_STD_CVT | V4L2_DV_BT_STD_GTF, + .capabilities = V4L2_DV_BT_CAP_PROGRESSIVE | + V4L2_DV_BT_CAP_REDUCED_BLANKING | + V4L2_DV_BT_CAP_CUSTOM, + }, +}; + +static int chv3_fb_enum_dv_timings_fallback(struct chv3_fb *fb, + struct v4l2_enum_dv_timings *timings) +{ + return v4l2_enum_dv_timings_cap(timings, &chv3_fb_fallback_dv_timings_cap, + NULL, NULL); +} + +static int chv3_fb_dv_timings_cap_fallback(struct chv3_fb *fb, + struct v4l2_dv_timings_cap *cap) +{ + *cap = chv3_fb_fallback_dv_timings_cap; + + return 0; +} + +static void chv3_fb_apply_dv_timings(struct chv3_fb *fb) +{ + struct v4l2_dv_timings timings; + int res; + + res = chv3_fb_query_dv_timings(fb, &timings); + if (res) + return; + + fb->timings = timings; + chv3_fb_set_format_resolution(fb, timings.bt.width, timings.bt.height); +} + +static int chv3_fb_querycap(struct file *file, void *fh, + struct v4l2_capability *cap) +{ + strscpy(cap->driver, DEVICE_NAME, sizeof(cap->driver)); + strscpy(cap->card, "Chameleon v3 video", sizeof(cap->card)); + + return 0; +} + +static int chv3_fb_g_fmt_vid_cap(struct file *file, void *fh, + struct v4l2_format *fmt) +{ + struct chv3_fb *fb = video_drvdata(file); + + fmt->fmt.pix = fb->pix_fmt; + + return 0; +} + +static int chv3_fb_enum_fmt_vid_cap(struct file *file, void *fh, + struct v4l2_fmtdesc *fmt) +{ + struct chv3_fb *fb = video_drvdata(file); + + if (fmt->index != 0) + return -EINVAL; + + fmt->flags = 0; + fmt->pixelformat = fb->pix_fmt.pixelformat; + + return 0; +} + +static int chv3_fb_enum_framesizes(struct file *file, void *fh, + struct v4l2_frmsizeenum *frm) +{ + struct chv3_fb *fb = video_drvdata(file); + + if (frm->index != 0) + return -EINVAL; + + if (frm->pixel_format != fb->pix_fmt.pixelformat) + return -EINVAL; + + frm->type = V4L2_FRMSIZE_TYPE_DISCRETE; + frm->discrete.width = fb->pix_fmt.width; + frm->discrete.height = fb->pix_fmt.height; + + return 0; +} + +static int chv3_fb_g_input(struct file *file, void *fh, unsigned int *index) +{ + *index = 0; + + return 0; +} + +static int chv3_fb_s_input(struct file *file, void *fh, unsigned int index) +{ + if (index != 0) + return -EINVAL; + + return 0; +} + +static int chv3_fb_enum_input(struct file *file, void *fh, + struct v4l2_input *input) +{ + if (input->index != 0) + return -EINVAL; + + strscpy(input->name, "input0", sizeof(input->name)); + input->type = V4L2_INPUT_TYPE_CAMERA; + input->capabilities = V4L2_IN_CAP_DV_TIMINGS; + + return 0; +} + +static int chv3_fb_g_edid(struct file *file, void *fh, + struct v4l2_edid *edid) +{ + struct chv3_fb *fb = video_drvdata(file); + int res; + + if (!fb->subdev) + return -ENOTTY; + + if (edid->pad != 0) + return -EINVAL; + + edid->pad = fb->subdev_source_pad; + res = v4l2_subdev_call(fb->subdev, pad, get_edid, edid); + edid->pad = 0; + + return res; +} + +static int chv3_fb_s_edid(struct file *file, void *fh, + struct v4l2_edid *edid) +{ + struct chv3_fb *fb = video_drvdata(file); + int res; + + if (!fb->subdev) + return -ENOTTY; + + if (edid->pad != 0) + return -EINVAL; + + edid->pad = fb->subdev_source_pad; + res = v4l2_subdev_call(fb->subdev, pad, set_edid, edid); + edid->pad = 0; + + return res; +} + +static int chv3_fb_s_dv_timings(struct file *file, void *fh, + struct v4l2_dv_timings *timings) +{ + struct chv3_fb *fb = video_drvdata(file); + + if (timings->bt.width == fb->timings.bt.width && + timings->bt.height == fb->timings.bt.height) + return 0; + + if (vb2_is_busy(&fb->queue)) + return -EBUSY; + + if (!v4l2_valid_dv_timings(timings, &chv3_fb_fallback_dv_timings_cap, NULL, NULL)) + return -ERANGE; + + fb->timings = *timings; + chv3_fb_set_format_resolution(fb, timings->bt.width, timings->bt.height); + + return 0; +} + +static int chv3_fb_g_dv_timings(struct file *file, void *fh, + struct v4l2_dv_timings *timings) +{ + struct chv3_fb *fb = video_drvdata(file); + + *timings = fb->timings; + return 0; +} + +static int chv3_fb_vidioc_query_dv_timings(struct file *file, void *fh, + struct v4l2_dv_timings *timings) +{ + struct chv3_fb *fb = video_drvdata(file); + + return chv3_fb_query_dv_timings(fb, timings); +} + +static int chv3_fb_enum_dv_timings(struct file *file, void *fh, + struct v4l2_enum_dv_timings *timings) +{ + struct chv3_fb *fb = video_drvdata(file); + int res; + + if (timings->pad != 0) + return -EINVAL; + + if (fb->subdev) { + timings->pad = fb->subdev_source_pad; + res = v4l2_subdev_call(fb->subdev, pad, enum_dv_timings, timings); + timings->pad = 0; + return res; + } else { + return chv3_fb_enum_dv_timings_fallback(fb, timings); + } +} + +static int chv3_fb_dv_timings_cap(struct file *file, void *fh, + struct v4l2_dv_timings_cap *cap) +{ + struct chv3_fb *fb = video_drvdata(file); + int res; + + if (cap->pad != 0) + return -EINVAL; + + if (fb->subdev) { + cap->pad = fb->subdev_source_pad; + res = v4l2_subdev_call(fb->subdev, pad, dv_timings_cap, cap); + cap->pad = 0; + return res; + } else { + return chv3_fb_dv_timings_cap_fallback(fb, cap); + } +} + +static int chv3_fb_subscribe_event(struct v4l2_fh *fh, + const struct v4l2_event_subscription *sub) +{ + switch (sub->type) { + case V4L2_EVENT_SOURCE_CHANGE: + return v4l2_src_change_event_subscribe(fh, sub); + } + + return v4l2_ctrl_subscribe_event(fh, sub); +} + +static const struct v4l2_ioctl_ops chv3_fb_v4l2_ioctl_ops = { + .vidioc_querycap = chv3_fb_querycap, + + .vidioc_enum_fmt_vid_cap = chv3_fb_enum_fmt_vid_cap, + .vidioc_g_fmt_vid_cap = chv3_fb_g_fmt_vid_cap, + .vidioc_s_fmt_vid_cap = chv3_fb_g_fmt_vid_cap, + .vidioc_try_fmt_vid_cap = chv3_fb_g_fmt_vid_cap, + + .vidioc_enum_framesizes = chv3_fb_enum_framesizes, + + .vidioc_enum_input = chv3_fb_enum_input, + .vidioc_g_input = chv3_fb_g_input, + .vidioc_s_input = chv3_fb_s_input, + .vidioc_g_edid = chv3_fb_g_edid, + .vidioc_s_edid = chv3_fb_s_edid, + + .vidioc_reqbufs = vb2_ioctl_reqbufs, + .vidioc_create_bufs = vb2_ioctl_create_bufs, + .vidioc_querybuf = vb2_ioctl_querybuf, + .vidioc_prepare_buf = vb2_ioctl_prepare_buf, + .vidioc_expbuf = vb2_ioctl_expbuf, + .vidioc_qbuf = vb2_ioctl_qbuf, + .vidioc_dqbuf = vb2_ioctl_dqbuf, + .vidioc_streamon = vb2_ioctl_streamon, + .vidioc_streamoff = vb2_ioctl_streamoff, + + .vidioc_s_dv_timings = chv3_fb_s_dv_timings, + .vidioc_g_dv_timings = chv3_fb_g_dv_timings, + .vidioc_query_dv_timings = chv3_fb_vidioc_query_dv_timings, + .vidioc_enum_dv_timings = chv3_fb_enum_dv_timings, + .vidioc_dv_timings_cap = chv3_fb_dv_timings_cap, + + .vidioc_subscribe_event = chv3_fb_subscribe_event, + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, +}; + +static int chv3_fb_queue_setup(struct vb2_queue *q, + unsigned int *nbuffers, unsigned int *nplanes, + unsigned int sizes[], struct device *alloc_devs[]) +{ + struct chv3_fb *fb = vb2_get_drv_priv(q); + + if (*nplanes) { + if (sizes[0] < fb->pix_fmt.sizeimage) + return -EINVAL; + return 0; + } + *nplanes = 1; + sizes[0] = fb->pix_fmt.sizeimage; + + return 0; +} + +/* + * There are two address registers: BUFFERA and BUFFERB. The framebuffer + * alternates writing between them (i.e. even frames go to BUFFERA, odd + * ones to BUFFERB). + * + * (buffer queue) > QUEUED ---> QUEUED ---> QUEUED ---> ... + * BUFFERA BUFFERB + * (hw writing to this) ^ + * (and then to this) ^ + * + * The buffer swapping happens at irq time. When an irq comes, the next + * frame is already assigned an address in the buffer queue. This gives + * the irq handler a whole frame's worth of time to update the buffer + * address register. + */ + +static dma_addr_t chv3_fb_buffer_dma_addr(struct chv3_fb_buffer *buf) +{ + return vb2_dma_contig_plane_dma_addr(&buf->vb.vb2_buf, 0); +} + +static void chv3_fb_start_frame(struct chv3_fb *fb, struct chv3_fb_buffer *buf) +{ + fb->writing_to_a = 1; + writel(chv3_fb_buffer_dma_addr(buf), fb->iobase + FB_BUFFERA); + writel(FB_EN_BIT, fb->iobase + FB_EN); +} + +static void chv3_fb_next_frame(struct chv3_fb *fb, struct chv3_fb_buffer *buf) +{ + u32 reg = fb->writing_to_a ? FB_BUFFERB : FB_BUFFERA; + + writel(chv3_fb_buffer_dma_addr(buf), fb->iobase + reg); +} + +static int chv3_fb_start_streaming(struct vb2_queue *q, unsigned int count) +{ + struct chv3_fb *fb = vb2_get_drv_priv(q); + struct chv3_fb_buffer *buf; + unsigned long flags; + + fb->sequence = 0; + writel(fb->pix_fmt.sizeimage, fb->iobase + FB_BUFFERSIZE); + + spin_lock_irqsave(&fb->bufs_lock, flags); + buf = list_first_entry_or_null(&fb->bufs, struct chv3_fb_buffer, link); + if (buf) { + chv3_fb_start_frame(fb, buf); + if (!list_is_last(&buf->link, &fb->bufs)) + chv3_fb_next_frame(fb, list_next_entry(buf, link)); + } + spin_unlock_irqrestore(&fb->bufs_lock, flags); + + return 0; +} + +static void chv3_fb_stop_streaming(struct vb2_queue *q) +{ + struct chv3_fb *fb = vb2_get_drv_priv(q); + struct chv3_fb_buffer *buf; + unsigned long flags; + + writel(0, fb->iobase + FB_EN); + + spin_lock_irqsave(&fb->bufs_lock, flags); + list_for_each_entry(buf, &fb->bufs, link) + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); + INIT_LIST_HEAD(&fb->bufs); + spin_unlock_irqrestore(&fb->bufs_lock, flags); +} + +static void chv3_fb_buf_queue(struct vb2_buffer *vb) +{ + struct chv3_fb *fb = vb2_get_drv_priv(vb->vb2_queue); + struct vb2_v4l2_buffer *v4l2_buf = to_vb2_v4l2_buffer(vb); + struct chv3_fb_buffer *buf = container_of(v4l2_buf, struct chv3_fb_buffer, vb); + bool first, second; + unsigned long flags; + + spin_lock_irqsave(&fb->bufs_lock, flags); + first = list_empty(&fb->bufs); + second = list_is_singular(&fb->bufs); + list_add_tail(&buf->link, &fb->bufs); + if (vb2_is_streaming(vb->vb2_queue)) { + if (first) + chv3_fb_start_frame(fb, buf); + else if (second) + chv3_fb_next_frame(fb, buf); + } + spin_unlock_irqrestore(&fb->bufs_lock, flags); +} + +static const struct vb2_ops chv3_fb_vb2_ops = { + .queue_setup = chv3_fb_queue_setup, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish = vb2_ops_wait_finish, + .start_streaming = chv3_fb_start_streaming, + .stop_streaming = chv3_fb_stop_streaming, + .buf_queue = chv3_fb_buf_queue, +}; + +static int chv3_fb_open(struct file *file) +{ + struct chv3_fb *fb = video_drvdata(file); + int res; + + mutex_lock(&fb->fb_lock); + res = v4l2_fh_open(file); + if (!res) { + if (v4l2_fh_is_singular_file(file)) + chv3_fb_apply_dv_timings(fb); + } + mutex_unlock(&fb->fb_lock); + + return res; +} + +static const struct v4l2_file_operations chv3_fb_v4l2_fops = { + .owner = THIS_MODULE, + .open = chv3_fb_open, + .release = vb2_fop_release, + .unlocked_ioctl = video_ioctl2, + .mmap = vb2_fop_mmap, + .poll = vb2_fop_poll, +}; + +static void chv3_fb_frame_irq(struct chv3_fb *fb) +{ + struct chv3_fb_buffer *buf; + + spin_lock(&fb->bufs_lock); + + buf = list_first_entry_or_null(&fb->bufs, struct chv3_fb_buffer, link); + if (!buf) + goto empty; + list_del(&buf->link); + + vb2_set_plane_payload(&buf->vb.vb2_buf, 0, fb->pix_fmt.sizeimage); + buf->vb.vb2_buf.timestamp = ktime_get_ns(); + buf->vb.sequence = fb->sequence++; + buf->vb.field = V4L2_FIELD_NONE; + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + + buf = list_first_entry_or_null(&fb->bufs, struct chv3_fb_buffer, link); + if (buf) { + fb->writing_to_a = !fb->writing_to_a; + if (!list_is_last(&buf->link, &fb->bufs)) + chv3_fb_next_frame(fb, list_next_entry(buf, link)); + } else { + writel(0, fb->iobase + FB_EN); + } +empty: + spin_unlock(&fb->bufs_lock); +} + +static void chv3_fb_error_irq(struct chv3_fb *fb) +{ + if (vb2_is_streaming(&fb->queue)) + vb2_queue_error(&fb->queue); +} + +static void chv3_fb_resolution_irq(struct chv3_fb *fb) +{ + static const struct v4l2_event event = { + .type = V4L2_EVENT_SOURCE_CHANGE, + .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION, + }; + + v4l2_event_queue(&fb->vdev, &event); + chv3_fb_error_irq(fb); +} + +static irqreturn_t chv3_fb_isr(int irq, void *data) +{ + struct chv3_fb *fb = data; + unsigned int reg; + + reg = readl(fb->iobase_irq + FB_IRQ_CLR); + if (!reg) + return IRQ_NONE; + + if (reg & FB_IRQ_BUFF0) + chv3_fb_frame_irq(fb); + if (reg & FB_IRQ_BUFF1) + chv3_fb_frame_irq(fb); + if (reg & FB_IRQ_RESOLUTION) + chv3_fb_resolution_irq(fb); + if (reg & FB_IRQ_ERROR) { + dev_warn(fb->dev, "framebuffer error: 0x%x\n", + readl(fb->iobase + FB_ERRORSTATUS)); + chv3_fb_error_irq(fb); + } + + writel(reg, fb->iobase_irq + FB_IRQ_CLR); + + return IRQ_HANDLED; +} + +static int chv3_fb_check_version(struct chv3_fb *fb) +{ + u32 version; + + version = readl(fb->iobase + FB_VERSION); + if (version != FB_VERSION_CURRENT) { + dev_err(fb->dev, + "wrong framebuffer version: expected %x, got %x\n", + FB_VERSION_CURRENT, version); + return -ENODEV; + } + return 0; +} + +static void chv3_fb_set_default_format(struct chv3_fb *fb, bool legacy_format) +{ + struct v4l2_pix_format *pix = &fb->pix_fmt; + + if (legacy_format) + pix->pixelformat = V4L2_PIX_FMT_BGRX32; + else + pix->pixelformat = V4L2_PIX_FMT_RGB24; + pix->field = V4L2_FIELD_NONE; + pix->colorspace = V4L2_COLORSPACE_SRGB; + + chv3_fb_set_format_resolution(fb, DEFAULT_WIDTH, DEFAULT_HEIGHT); +} + +static void chv3_fb_set_default_timings(struct chv3_fb *fb) +{ + memset(&fb->timings, 0, sizeof(fb->timings)); + fb->timings.type = V4L2_DV_BT_656_1120; + fb->timings.bt.width = DEFAULT_WIDTH; + fb->timings.bt.height = DEFAULT_HEIGHT; +} + +#define notifier_to_fb(nf) container_of(nf, struct chv3_fb, notifier) + +static int chv3_fb_async_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *subdev, + struct v4l2_async_connection *asc) +{ + struct chv3_fb *fb = notifier_to_fb(notifier); + int pad; + + pad = media_entity_get_fwnode_pad(&subdev->entity, asc->match.fwnode, + MEDIA_PAD_FL_SOURCE); + if (pad < 0) + return pad; + + fb->subdev = subdev; + fb->subdev_source_pad = pad; + + return 0; +} + +static void chv3_fb_async_notify_unbind(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *subdev, + struct v4l2_async_connection *asc) +{ + struct chv3_fb *fb = notifier_to_fb(notifier); + + video_unregister_device(&fb->vdev); +} + +static int chv3_fb_async_notify_complete(struct v4l2_async_notifier *notifier) +{ + struct chv3_fb *fb = notifier_to_fb(notifier); + + return video_register_device(&fb->vdev, VFL_TYPE_VIDEO, -1); +} + +static const struct v4l2_async_notifier_operations chv3_fb_async_notify_ops = { + .bound = chv3_fb_async_notify_bound, + .unbind = chv3_fb_async_notify_unbind, + .complete = chv3_fb_async_notify_complete, +}; + +static int chv3_fb_fallback_init(struct chv3_fb *fb) +{ + fb->subdev = NULL; + fb->subdev_source_pad = 0; + + return video_register_device(&fb->vdev, VFL_TYPE_VIDEO, -1); +} + +static int chv3_fb_fwnode_init(struct chv3_fb *fb) +{ + struct v4l2_async_connection *asc; + struct fwnode_handle *endpoint; + int res; + + endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(fb->dev), NULL); + if (!endpoint) + return -EINVAL; + + v4l2_async_nf_init(&fb->notifier, &fb->v4l2_dev); + + asc = v4l2_async_nf_add_fwnode_remote(&fb->notifier, endpoint, + struct v4l2_async_connection); + fwnode_handle_put(endpoint); + + if (IS_ERR(asc)) + return PTR_ERR(asc); + + fb->notifier.ops = &chv3_fb_async_notify_ops; + res = v4l2_async_nf_register(&fb->notifier); + if (res) { + v4l2_async_nf_cleanup(&fb->notifier); + return res; + } + + return 0; +} + +static int chv3_fb_probe(struct platform_device *pdev) +{ + struct chv3_fb *fb; + bool legacy_format; + bool no_endpoint; + int res; + int irq; + + fb = devm_kzalloc(&pdev->dev, sizeof(*fb), GFP_KERNEL); + if (!fb) + return -ENOMEM; + fb->dev = &pdev->dev; + platform_set_drvdata(pdev, fb); + + /* map register space */ + fb->iobase = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(fb->iobase)) + return PTR_ERR(fb->iobase); + + fb->iobase_irq = devm_platform_ioremap_resource(pdev, 1); + if (IS_ERR(fb->iobase_irq)) + return PTR_ERR(fb->iobase_irq); + + /* check hw version */ + res = chv3_fb_check_version(fb); + if (res) + return res; + + /* setup interrupts */ + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return -ENXIO; + res = devm_request_irq(&pdev->dev, irq, chv3_fb_isr, 0, DEVICE_NAME, fb); + if (res) + return res; + + /* initialize v4l2_device */ + res = v4l2_device_register(&pdev->dev, &fb->v4l2_dev); + if (res) + return res; + + /* initialize vb2 queue */ + fb->queue.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + fb->queue.io_modes = VB2_MMAP | VB2_DMABUF; + fb->queue.dev = &pdev->dev; + fb->queue.lock = &fb->fb_lock; + fb->queue.ops = &chv3_fb_vb2_ops; + fb->queue.mem_ops = &vb2_dma_contig_memops; + fb->queue.drv_priv = fb; + fb->queue.buf_struct_size = sizeof(struct chv3_fb_buffer); + fb->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; + res = vb2_queue_init(&fb->queue); + if (res) + goto error; + + /* initialize video_device */ + strscpy(fb->vdev.name, DEVICE_NAME, sizeof(fb->vdev.name)); + fb->vdev.fops = &chv3_fb_v4l2_fops; + fb->vdev.ioctl_ops = &chv3_fb_v4l2_ioctl_ops; + fb->vdev.lock = &fb->fb_lock; + fb->vdev.release = video_device_release_empty; + fb->vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; + fb->vdev.v4l2_dev = &fb->v4l2_dev; + fb->vdev.queue = &fb->queue; + video_set_drvdata(&fb->vdev, fb); + + /* read other DT properties */ + legacy_format = device_property_read_bool(&pdev->dev, "google,legacy-format"); + no_endpoint = device_property_read_bool(&pdev->dev, "google,no-endpoint"); + + if (no_endpoint) + res = chv3_fb_fallback_init(fb); + else + res = chv3_fb_fwnode_init(fb); + if (res) + goto error; + + /* initialize rest of driver struct */ + INIT_LIST_HEAD(&fb->bufs); + spin_lock_init(&fb->bufs_lock); + mutex_init(&fb->fb_lock); + + chv3_fb_set_default_format(fb, legacy_format); + chv3_fb_set_default_timings(fb); + + /* initialize hw */ + writel(FB_RESET_BIT, fb->iobase + FB_RESET); + writel(FB_DATARATE_DOUBLE, fb->iobase + FB_DATARATE); + writel(FB_PIXELMODE_DOUBLE, fb->iobase + FB_PIXELMODE); + if (legacy_format) + writel(FB_DMAFORMAT_8BPC_LEGACY, fb->iobase + FB_DMAFORMAT); + else + writel(FB_DMAFORMAT_8BPC, fb->iobase + FB_DMAFORMAT); + + writel(FB_IRQ_ALL, fb->iobase_irq + FB_IRQ_MASK); + + return 0; + +error: + v4l2_device_unregister(&fb->v4l2_dev); + + return res; +} + +static void chv3_fb_remove(struct platform_device *pdev) +{ + struct chv3_fb *fb = platform_get_drvdata(pdev); + + /* disable interrupts */ + writel(0, fb->iobase_irq + FB_IRQ_MASK); + + v4l2_async_nf_unregister(&fb->notifier); + v4l2_async_nf_cleanup(&fb->notifier); + v4l2_device_unregister(&fb->v4l2_dev); +} + +static const struct of_device_id chv3_fb_match_table[] = { + { .compatible = "google,chv3-fb" }, + { }, +}; + +static struct platform_driver chv3_fb_platform_driver = { + .probe = chv3_fb_probe, + .remove_new = chv3_fb_remove, + .driver = { + .name = DEVICE_NAME, + .of_match_table = chv3_fb_match_table, + }, +}; + +module_platform_driver(chv3_fb_platform_driver); + +MODULE_AUTHOR("Paweł Anikiel "); +MODULE_DESCRIPTION("Google Chameleon v3 video framebuffer driver"); +MODULE_LICENSE("GPL"); From patchwork Mon Feb 12 13:13:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Anikiel?= X-Patchwork-Id: 199792 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2432236dyd; Mon, 12 Feb 2024 05:39:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVW/LXikPhqLbuvfdTywELv6iWNeAbV7U4vgFcwYdzIv+Bo8TakndtXREzaUSUnWYXpp3J/oIpu2fmqpNhYllPoHdIx3Q== X-Google-Smtp-Source: AGHT+IGsWlzg228ujgZDNvP/ce7HflwTqQWOXgIh7oLSTtcnjQNX86qWCt7x2t7T++UAzQWNpClu X-Received: by 2002:a92:2907:0:b0:363:c47c:f64e with SMTP id l7-20020a922907000000b00363c47cf64emr7887056ilg.4.1707745199724; Mon, 12 Feb 2024 05:39:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707745199; cv=pass; d=google.com; s=arc-20160816; b=lmmz42LAt9HLtp/7mmKneqTSkKTTnenW6u+C/A16i7CrxvdQPW6HNvSMKKHvQrKUc+ COTGZILpW+XrxIjQ6YNibTPC11zu6cSAULAzfb7tbiKnfZAj9APrrHz2w8umEWLwuEBz uqG3Rd4L0gvxvgC0FQeCfo4dKIs2Fi/e2smvDyqdrWPg/bazGEKL1eTZfbbUA0w/XeVm cwStIFoB1FWtf2z5Z+c7QBNE1bD5ibcdFypg5Dd8v+QdEkSnxbVw9zBMRvFjGu1plei3 ojmRTandHt7G/clSNsp/01QRs2ObutI+3LoU2vkNHK1CJUGrHZotaDM9g91kWNFFfxYf QvZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=C857fcvjN2Q61CMGefzqTDLbKskpX9Jvk37xAZm0WZQ=; fh=Njsx19AE5u6d5XBeWvAJRotZk0M0sKgMqY+Zi1x38mM=; b=Agjnkjxu6uIo149YNx5Q+aEsaxwaRqBP6jhoAOS88bKQBe+tOM31tIPbjxSTUfK2Tg Yk0amB7QAaCyemzu47KAR3P9ogzz6pqQ0mXez8yR38TBUVQiIUlO3y8+155qdUzK/Z2E y6FGAh00LJZGFuspZL6xLxUAzlGHVApJlESj/LTbgGSPLgD4ecqSkE1Ay61ADeAGN1rc SHeLrOoHwBZv0Ux1nzZssMKpxsAgdYON1zpuC8raAU+15/pZR3FtmL75naJsWsa1PxLc bsZppVE66d3q5mOvGULmlhyRzbNFxipG5PiQoxUgj3k1yQ00ocfGzwa7aLeg2vvwfTzs zixg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=GKpcq2Eg; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61638-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61638-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCVjjbaHSZrX+Vcyz5sTUsRnrOnQH40CFpV8BzylNDMNHg7wnYlwM3up5rlRoIuiUZ4eHW9FQ1rctcm97aTX3aXS7ClJ8g== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z3-20020a63ac43000000b005dc4f8a376asi247130pgn.884.2024.02.12.05.39.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:39:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61638-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=GKpcq2Eg; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61638-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61638-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A2282B278EF for ; Mon, 12 Feb 2024 13:22:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F909482C5; Mon, 12 Feb 2024 13:14:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GKpcq2Eg" Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2601E41A85 for ; Mon, 12 Feb 2024 13:14:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743667; cv=none; b=fTQ4oVs/KuW4HB8dck5357icHg0YhGyb9zJct/xEUKDz62yujvL6vju5nEWIbgTZnoqobzEVDLi2duCanmQACiwGo57bCag+HM1qDfBvQ4TNyVdWEDjvqra5IsQ0yE7J4bKhRJ30Bu+Md2symOmeI68n0Z6XcleT3Bam7mHNfFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743667; c=relaxed/simple; bh=EduHQTMkW7M9PuCv7DD8a87vLU/tqTiTdiEeV+xNUlQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=endy3QSiGbQjk4+hEdF+Ci0IJC9AwdNLZDtqYAT8V5OV97ZuwyAlX+IVJUgt6MJcCVzqoQfgDOHAV+Q/9AHuT/+jriQZwxy6R1FPmuXGQgAIhrQkAXxq846r82RgIROaQw1XoPqwyADEAeMlWTyEl5JkPfLOH1ocrEdTUgmYMmI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GKpcq2Eg; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-40fb505c97aso19809445e9.3 for ; Mon, 12 Feb 2024 05:14:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707743663; x=1708348463; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=C857fcvjN2Q61CMGefzqTDLbKskpX9Jvk37xAZm0WZQ=; b=GKpcq2EgIwaLGMey1DaJ8Lju3zH/tPZ/MWdR39oo5oS00nvHzSNityNdG7ic42oxOA BhUPKreq8Yws8iciCOxUJN3Ok/52gQk3fuVhmRFpFyFw2y0hsmnp7qtWelA8FEQhPLo9 wyFJmN4IcPi8+Lyh2MwJ2hegGPoO0zJjp7rJ6qWneoGTF/4Vym5/VqGoAgYAr6NRQbxi 9jpRz5rCDxryOvWh3wN9VuGrsm2UHTBeMjbvcumRqJNz3ApDT30L4ux5m5lAeyYpFmHW 6CJURSVZnsL2k6t7XsvIRkbHo/SqxM6k1nR2ENJBwN/I1/ha0h65ys8x1vfNYklsKufz b0eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707743663; x=1708348463; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=C857fcvjN2Q61CMGefzqTDLbKskpX9Jvk37xAZm0WZQ=; b=XNjPW+MD2nOabm0iQK2+k5mXXWYfZm4FlHk5oqDkxD5M7PR1EnO89iRRyUx/Wars+D 780SJkjt1dlOd6FcTRWrp6iW0Z/Qs3Av6VNdQzvXPgzkLqvZDRNDWZFOIvm1oHKaxNtr ERHwqc8VZfE9avxc/2O6IVZmn38DGEz6Z0hgWSWo+WyR+4JAzGc4i9LO1+fUnxsa+R68 3yOp/mgAhQXCaDOK3z8VtLokrpD8DbWM2etJr0MlBhavYt7C/YhJaEHEFx8FVcXLJuJ4 AjVUX4B9EyntGPOWEhZy3gPUXnaO9TahSFJAFFmCy2zL/+rZi7yNX01Ytqe42UGazKfQ dXFw== X-Forwarded-Encrypted: i=1; AJvYcCUwbBUzjH7v9bgwY5njrxrp3PSKbY0VXtDJBclSerK+dLIHRetBRS2K29KKcfCl2LBm5N8x5yI96oLqlmOAEhndnHj3aw9+83Jz+qHM X-Gm-Message-State: AOJu0YzR0vsIcmJz8x6QN5v1SFlfdXabbF+a94KOVO2FpEAfOT3jxgnG D+fJw7kRm3o3xIw33DhnjGJVjNuIm8UdDgGr+Ha4+QLwgBosNMl3eyo3KZp+tVphDWZaAmq9sQK 0UHm+4NhC+w== X-Received: from szatan.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:2d83]) (user=panikiel job=sendgmr) by 2002:a5d:5a1a:0:b0:33b:1da0:a7cb with SMTP id bq26-20020a5d5a1a000000b0033b1da0a7cbmr36157wrb.4.1707743663594; Mon, 12 Feb 2024 05:14:23 -0800 (PST) Date: Mon, 12 Feb 2024 13:13:17 +0000 In-Reply-To: <20240212131323.2162161-1-panikiel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240212131323.2162161-1-panikiel@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240212131323.2162161-4-panikiel@google.com> Subject: [PATCH 3/9] drm/dp_mst: Move DRM-independent structures to separate header From: " =?utf-8?q?Pawe=C5=82_Anikiel?= " To: airlied@gmail.com, akpm@linux-foundation.org, conor+dt@kernel.org, daniel@ffwll.ch, dinguyen@kernel.org, hverkuil-cisco@xs4all.nl, krzysztof.kozlowski+dt@linaro.org, maarten.lankhorst@linux.intel.com, mchehab@kernel.org, mripard@kernel.org, robh+dt@kernel.org, tzimmermann@suse.de Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, chromeos-krk-upstreaming@google.com, ribalda@chromium.org, " =?utf-8?q?Pawe?= =?utf-8?q?=C5=82_Anikiel?= " X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790700630520309984 X-GMAIL-MSGID: 1790700630520309984 Move structures describing MST sideband messages into a separate header so that non-DRM code can use them. Signed-off-by: Paweł Anikiel --- include/drm/display/drm_dp_mst.h | 238 ++++++++++++++++++++++++ include/drm/display/drm_dp_mst_helper.h | 232 +---------------------- 2 files changed, 239 insertions(+), 231 deletions(-) create mode 100644 include/drm/display/drm_dp_mst.h diff --git a/include/drm/display/drm_dp_mst.h b/include/drm/display/drm_dp_mst.h new file mode 100644 index 000000000000..4e398bfd3ee3 --- /dev/null +++ b/include/drm/display/drm_dp_mst.h @@ -0,0 +1,238 @@ +/* SPDX-License-Identifier: MIT */ + +#ifndef _DRM_DP_MST_H_ +#define _DRM_DP_MST_H_ + +#include + +struct drm_dp_nak_reply { + u8 guid[16]; + u8 reason; + u8 nak_data; +}; + +struct drm_dp_link_address_ack_reply { + u8 guid[16]; + u8 nports; + struct drm_dp_link_addr_reply_port { + bool input_port; + u8 peer_device_type; + u8 port_number; + bool mcs; + bool ddps; + bool legacy_device_plug_status; + u8 dpcd_revision; + u8 peer_guid[16]; + u8 num_sdp_streams; + u8 num_sdp_stream_sinks; + } ports[16]; +}; + +struct drm_dp_remote_dpcd_read_ack_reply { + u8 port_number; + u8 num_bytes; + u8 bytes[255]; +}; + +struct drm_dp_remote_dpcd_write_ack_reply { + u8 port_number; +}; + +struct drm_dp_remote_dpcd_write_nak_reply { + u8 port_number; + u8 reason; + u8 bytes_written_before_failure; +}; + +struct drm_dp_remote_i2c_read_ack_reply { + u8 port_number; + u8 num_bytes; + u8 bytes[255]; +}; + +struct drm_dp_remote_i2c_read_nak_reply { + u8 port_number; + u8 nak_reason; + u8 i2c_nak_transaction; +}; + +struct drm_dp_remote_i2c_write_ack_reply { + u8 port_number; +}; + +struct drm_dp_query_stream_enc_status_ack_reply { + /* Bit[23:16]- Stream Id */ + u8 stream_id; + + /* Bit[15]- Signed */ + bool reply_signed; + + /* Bit[10:8]- Stream Output Sink Type */ + bool unauthorizable_device_present; + bool legacy_device_present; + bool query_capable_device_present; + + /* Bit[12:11]- Stream Output CP Type */ + bool hdcp_1x_device_present; + bool hdcp_2x_device_present; + + /* Bit[4]- Stream Authentication */ + bool auth_completed; + + /* Bit[3]- Stream Encryption */ + bool encryption_enabled; + + /* Bit[2]- Stream Repeater Function Present */ + bool repeater_present; + + /* Bit[1:0]- Stream State */ + u8 state; +}; + +#define DRM_DP_MAX_SDP_STREAMS 16 +struct drm_dp_allocate_payload { + u8 port_number; + u8 number_sdp_streams; + u8 vcpi; + u16 pbn; + u8 sdp_stream_sink[DRM_DP_MAX_SDP_STREAMS]; +}; + +struct drm_dp_allocate_payload_ack_reply { + u8 port_number; + u8 vcpi; + u16 allocated_pbn; +}; + +struct drm_dp_connection_status_notify { + u8 guid[16]; + u8 port_number; + bool legacy_device_plug_status; + bool displayport_device_plug_status; + bool message_capability_status; + bool input_port; + u8 peer_device_type; +}; + +struct drm_dp_remote_dpcd_read { + u8 port_number; + u32 dpcd_address; + u8 num_bytes; +}; + +struct drm_dp_remote_dpcd_write { + u8 port_number; + u32 dpcd_address; + u8 num_bytes; + u8 *bytes; +}; + +#define DP_REMOTE_I2C_READ_MAX_TRANSACTIONS 4 +struct drm_dp_remote_i2c_read { + u8 num_transactions; + u8 port_number; + struct drm_dp_remote_i2c_read_tx { + u8 i2c_dev_id; + u8 num_bytes; + u8 *bytes; + u8 no_stop_bit; + u8 i2c_transaction_delay; + } transactions[DP_REMOTE_I2C_READ_MAX_TRANSACTIONS]; + u8 read_i2c_device_id; + u8 num_bytes_read; +}; + +struct drm_dp_remote_i2c_write { + u8 port_number; + u8 write_i2c_device_id; + u8 num_bytes; + u8 *bytes; +}; + +struct drm_dp_query_stream_enc_status { + u8 stream_id; + u8 client_id[7]; /* 56-bit nonce */ + u8 stream_event; + bool valid_stream_event; + u8 stream_behavior; + u8 valid_stream_behavior; +}; + +/* this covers ENUM_RESOURCES, POWER_DOWN_PHY, POWER_UP_PHY */ +struct drm_dp_port_number_req { + u8 port_number; +}; + +struct drm_dp_enum_path_resources_ack_reply { + u8 port_number; + bool fec_capable; + u16 full_payload_bw_number; + u16 avail_payload_bw_number; +}; + +/* covers POWER_DOWN_PHY, POWER_UP_PHY */ +struct drm_dp_port_number_rep { + u8 port_number; +}; + +struct drm_dp_query_payload { + u8 port_number; + u8 vcpi; +}; + +struct drm_dp_resource_status_notify { + u8 port_number; + u8 guid[16]; + u16 available_pbn; +}; + +struct drm_dp_query_payload_ack_reply { + u8 port_number; + u16 allocated_pbn; +}; + +struct drm_dp_sideband_msg_req_body { + u8 req_type; + union ack_req { + struct drm_dp_connection_status_notify conn_stat; + struct drm_dp_port_number_req port_num; + struct drm_dp_resource_status_notify resource_stat; + + struct drm_dp_query_payload query_payload; + struct drm_dp_allocate_payload allocate_payload; + + struct drm_dp_remote_dpcd_read dpcd_read; + struct drm_dp_remote_dpcd_write dpcd_write; + + struct drm_dp_remote_i2c_read i2c_read; + struct drm_dp_remote_i2c_write i2c_write; + + struct drm_dp_query_stream_enc_status enc_status; + } u; +}; + +struct drm_dp_sideband_msg_reply_body { + u8 reply_type; + u8 req_type; + union ack_replies { + struct drm_dp_nak_reply nak; + struct drm_dp_link_address_ack_reply link_addr; + struct drm_dp_port_number_rep port_number; + + struct drm_dp_enum_path_resources_ack_reply path_resources; + struct drm_dp_allocate_payload_ack_reply allocate_payload; + struct drm_dp_query_payload_ack_reply query_payload; + + struct drm_dp_remote_dpcd_read_ack_reply remote_dpcd_read_ack; + struct drm_dp_remote_dpcd_write_ack_reply remote_dpcd_write_ack; + struct drm_dp_remote_dpcd_write_nak_reply remote_dpcd_write_nack; + + struct drm_dp_remote_i2c_read_ack_reply remote_i2c_read_ack; + struct drm_dp_remote_i2c_read_nak_reply remote_i2c_read_nack; + struct drm_dp_remote_i2c_write_ack_reply remote_i2c_write_ack; + + struct drm_dp_query_stream_enc_status_ack_reply enc_status; + } u; +}; + +#endif diff --git a/include/drm/display/drm_dp_mst_helper.h b/include/drm/display/drm_dp_mst_helper.h index 9b19d8bd520a..61add6f6accd 100644 --- a/include/drm/display/drm_dp_mst_helper.h +++ b/include/drm/display/drm_dp_mst_helper.h @@ -23,6 +23,7 @@ #define _DRM_DP_MST_HELPER_H_ #include +#include #include #include #include @@ -248,237 +249,6 @@ struct drm_dp_mst_branch { u8 guid[16]; }; - -struct drm_dp_nak_reply { - u8 guid[16]; - u8 reason; - u8 nak_data; -}; - -struct drm_dp_link_address_ack_reply { - u8 guid[16]; - u8 nports; - struct drm_dp_link_addr_reply_port { - bool input_port; - u8 peer_device_type; - u8 port_number; - bool mcs; - bool ddps; - bool legacy_device_plug_status; - u8 dpcd_revision; - u8 peer_guid[16]; - u8 num_sdp_streams; - u8 num_sdp_stream_sinks; - } ports[16]; -}; - -struct drm_dp_remote_dpcd_read_ack_reply { - u8 port_number; - u8 num_bytes; - u8 bytes[255]; -}; - -struct drm_dp_remote_dpcd_write_ack_reply { - u8 port_number; -}; - -struct drm_dp_remote_dpcd_write_nak_reply { - u8 port_number; - u8 reason; - u8 bytes_written_before_failure; -}; - -struct drm_dp_remote_i2c_read_ack_reply { - u8 port_number; - u8 num_bytes; - u8 bytes[255]; -}; - -struct drm_dp_remote_i2c_read_nak_reply { - u8 port_number; - u8 nak_reason; - u8 i2c_nak_transaction; -}; - -struct drm_dp_remote_i2c_write_ack_reply { - u8 port_number; -}; - -struct drm_dp_query_stream_enc_status_ack_reply { - /* Bit[23:16]- Stream Id */ - u8 stream_id; - - /* Bit[15]- Signed */ - bool reply_signed; - - /* Bit[10:8]- Stream Output Sink Type */ - bool unauthorizable_device_present; - bool legacy_device_present; - bool query_capable_device_present; - - /* Bit[12:11]- Stream Output CP Type */ - bool hdcp_1x_device_present; - bool hdcp_2x_device_present; - - /* Bit[4]- Stream Authentication */ - bool auth_completed; - - /* Bit[3]- Stream Encryption */ - bool encryption_enabled; - - /* Bit[2]- Stream Repeater Function Present */ - bool repeater_present; - - /* Bit[1:0]- Stream State */ - u8 state; -}; - -#define DRM_DP_MAX_SDP_STREAMS 16 -struct drm_dp_allocate_payload { - u8 port_number; - u8 number_sdp_streams; - u8 vcpi; - u16 pbn; - u8 sdp_stream_sink[DRM_DP_MAX_SDP_STREAMS]; -}; - -struct drm_dp_allocate_payload_ack_reply { - u8 port_number; - u8 vcpi; - u16 allocated_pbn; -}; - -struct drm_dp_connection_status_notify { - u8 guid[16]; - u8 port_number; - bool legacy_device_plug_status; - bool displayport_device_plug_status; - bool message_capability_status; - bool input_port; - u8 peer_device_type; -}; - -struct drm_dp_remote_dpcd_read { - u8 port_number; - u32 dpcd_address; - u8 num_bytes; -}; - -struct drm_dp_remote_dpcd_write { - u8 port_number; - u32 dpcd_address; - u8 num_bytes; - u8 *bytes; -}; - -#define DP_REMOTE_I2C_READ_MAX_TRANSACTIONS 4 -struct drm_dp_remote_i2c_read { - u8 num_transactions; - u8 port_number; - struct drm_dp_remote_i2c_read_tx { - u8 i2c_dev_id; - u8 num_bytes; - u8 *bytes; - u8 no_stop_bit; - u8 i2c_transaction_delay; - } transactions[DP_REMOTE_I2C_READ_MAX_TRANSACTIONS]; - u8 read_i2c_device_id; - u8 num_bytes_read; -}; - -struct drm_dp_remote_i2c_write { - u8 port_number; - u8 write_i2c_device_id; - u8 num_bytes; - u8 *bytes; -}; - -struct drm_dp_query_stream_enc_status { - u8 stream_id; - u8 client_id[7]; /* 56-bit nonce */ - u8 stream_event; - bool valid_stream_event; - u8 stream_behavior; - u8 valid_stream_behavior; -}; - -/* this covers ENUM_RESOURCES, POWER_DOWN_PHY, POWER_UP_PHY */ -struct drm_dp_port_number_req { - u8 port_number; -}; - -struct drm_dp_enum_path_resources_ack_reply { - u8 port_number; - bool fec_capable; - u16 full_payload_bw_number; - u16 avail_payload_bw_number; -}; - -/* covers POWER_DOWN_PHY, POWER_UP_PHY */ -struct drm_dp_port_number_rep { - u8 port_number; -}; - -struct drm_dp_query_payload { - u8 port_number; - u8 vcpi; -}; - -struct drm_dp_resource_status_notify { - u8 port_number; - u8 guid[16]; - u16 available_pbn; -}; - -struct drm_dp_query_payload_ack_reply { - u8 port_number; - u16 allocated_pbn; -}; - -struct drm_dp_sideband_msg_req_body { - u8 req_type; - union ack_req { - struct drm_dp_connection_status_notify conn_stat; - struct drm_dp_port_number_req port_num; - struct drm_dp_resource_status_notify resource_stat; - - struct drm_dp_query_payload query_payload; - struct drm_dp_allocate_payload allocate_payload; - - struct drm_dp_remote_dpcd_read dpcd_read; - struct drm_dp_remote_dpcd_write dpcd_write; - - struct drm_dp_remote_i2c_read i2c_read; - struct drm_dp_remote_i2c_write i2c_write; - - struct drm_dp_query_stream_enc_status enc_status; - } u; -}; - -struct drm_dp_sideband_msg_reply_body { - u8 reply_type; - u8 req_type; - union ack_replies { - struct drm_dp_nak_reply nak; - struct drm_dp_link_address_ack_reply link_addr; - struct drm_dp_port_number_rep port_number; - - struct drm_dp_enum_path_resources_ack_reply path_resources; - struct drm_dp_allocate_payload_ack_reply allocate_payload; - struct drm_dp_query_payload_ack_reply query_payload; - - struct drm_dp_remote_dpcd_read_ack_reply remote_dpcd_read_ack; - struct drm_dp_remote_dpcd_write_ack_reply remote_dpcd_write_ack; - struct drm_dp_remote_dpcd_write_nak_reply remote_dpcd_write_nack; - - struct drm_dp_remote_i2c_read_ack_reply remote_i2c_read_ack; - struct drm_dp_remote_i2c_read_nak_reply remote_i2c_read_nack; - struct drm_dp_remote_i2c_write_ack_reply remote_i2c_write_ack; - - struct drm_dp_query_stream_enc_status_ack_reply enc_status; - } u; -}; - /* msg is queued to be put into a slot */ #define DRM_DP_SIDEBAND_TX_QUEUED 0 /* msg has started transmitting on a slot - still on msgq */ From patchwork Mon Feb 12 13:13:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Anikiel?= X-Patchwork-Id: 199764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2422786dyd; Mon, 12 Feb 2024 05:22:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW12tylcCavsTsJ9h3BZH0LsQeMgC+28wdMyPW6xaaTEpNtx2cWqAsDgr88wp34zUcyTi8o1COEU4mzuepznTvlPxldRQ== X-Google-Smtp-Source: AGHT+IEwJ4FEwVV1odCikfeT0cfUyhtDD503IfQ6M0qu5m04vccDCd8F6I0XkdUlvjbLlINZdzvK X-Received: by 2002:a17:906:134d:b0:a3c:ccb9:e472 with SMTP id x13-20020a170906134d00b00a3cccb9e472mr946214ejb.27.1707744165929; Mon, 12 Feb 2024 05:22:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707744165; cv=pass; d=google.com; s=arc-20160816; b=JtlMEh4fq67Ik358hJFXvk6MIrPFC7Lc/6Pg5HbjUR58n870UkvC8rRHtF2Rkx3I+t 1jq8CkNmD8VfSRRWdpd5MxfAURZvZuuYm2OOZP/glTsbVrgr9TIqy53MedRUSifnGkzg /Z1rt0dzWHRL2apjTcPPgdlMSYxyEY4HzaVEwgiL4xCjMok5ircT9332cOs2nzdDEi2R QSqL29Lo4gcAKGhyOPeSiMmD0a5JsOZQMsKk7AHLWVc4y1FMPI6pyPjXIXaGlaewthld A3WmC9C1qhIKWVVxPDXtOXJrMCJyHxcvRuTL+Beo772V9mqoL4k2VyWeViHn+63JxyBR 4Q2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=8xYmC6/7GB0cnLvoqQ6/O63HTLhsqtwrPQr/DNWfuhA=; fh=wSy7HuZ4kGVz4CCvh8BqMMfN7Q+LERijkvAHrmMJ9Cs=; b=Pq4XO7zyS33tsHbxz441MO66M6k7SFEOpbVXUI3G+bO9xfyeRu+LoirgNmmzmd16SG E/p69q+s4vSxRhOutpwa99qHGuy+3HTxXSwcHptPnLCkADNYNRp3FBoQzjm4n4anJ+s6 53rs7TU/EJFRi4nnSPnxWa4kOZx4MhXXhUUFRYDmoKjbp1FisCP74XZakb6U4AJJeU5v /5K3pSY8p8E59MmvghaKwQinJIdhQLX+m3YN+b9scIsAOmtkHbLmgNSV3yJhjDVWoR4m 8J56Y221BgQoZqe8towod7BXCttSHJ8OY+1HCkkaEB3hiRdNtN2oppoE79+qWZZpL6P8 GM7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ERFJ23DD; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61640-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61640-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCXiuQlje7lfdFsmo1eKhf/+DVkwwVWkO+HDsLvNe7ELgD7oFJMkN5+UD81qqpMyaCdkDpGrJZFjJsjHfMoaJySEsVtD8g== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lg3-20020a170906f88300b00a389b078afesi188654ejb.996.2024.02.12.05.22.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:22:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61640-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ERFJ23DD; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61640-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61640-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5B7DA1F2091B for ; Mon, 12 Feb 2024 13:22:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06EC0495CC; Mon, 12 Feb 2024 13:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ERFJ23DD" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4144F4597C for ; Mon, 12 Feb 2024 13:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743669; cv=none; b=RCk0hHd65ED+/dVce/eR2O9NUa9dmy/khXNYpJwACYSNFB0hUcP/Pk0JWLdG6P0510OM6TMsD593rhUad5YyS6w98ALRNTnRYetIGvGAGiRskgaZ9f2qAQCyD5xrk0OrW/w2wfKAZcEnq4drdVppwRO2ZkR8c+wLiLQmMRP9gfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743669; c=relaxed/simple; bh=a9pxujH5PHZG0UGOA2G3s/Ee5bI2Qul5wfUj2II7oQM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=f3mI7Qc1A/rMDYvRFoHiJCb3vdlp68t3rTQvVWlvnZsM+6cMQ6H3rMlvXTieVNyXw4fZBee+EDOJZ9v1xcB8n8aqJ/+HhHrts8L3EmMW03B6c8CNtArGzgFndEUGQBQQ+A2YiVn648oUr7p1DlCJJxRmacIiTJFFHWHhqw+eceA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ERFJ23DD; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dbe9e13775aso4864416276.1 for ; Mon, 12 Feb 2024 05:14:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707743666; x=1708348466; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=8xYmC6/7GB0cnLvoqQ6/O63HTLhsqtwrPQr/DNWfuhA=; b=ERFJ23DD8hfWbfKTs8r5GBhmKa25ypfb55bv5P1euHXG+2Pp4e08H9H73JhmYQtd+5 CFsRLKXdrMuKi/TUmDYHnWo9gc/vY4aUUyHbQ0akJ3s2ZFimMTIc9w/oadkhcu+0yBIw ZD2R2KXu1aORsSc6TkKFWjeQ2W1ggaebYSAjbbH6yOPKyPdW5ndYHxxywA3xHi6gDMD6 sKCqiAY8I9gW9Nzbya+kUIYRsoxaj+dbW9uGp00OrHxPYL1FGELVQsTiF5HnvYTBiWd7 eRbqYrZaSzOmETJCUosGLOdKy0eq3SLeM8XGll0yPCoLCvF/AZJHhXW6zJzi8jLT+Jjh rt6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707743666; x=1708348466; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=8xYmC6/7GB0cnLvoqQ6/O63HTLhsqtwrPQr/DNWfuhA=; b=ammA61rrvDDh+ndJ+9/iJfsJHkffAEfzy2AoY66sVSsfoPnEvTT4iDt5B48CTFgzNH pLs7RfT3WZdfLCeDpU11sNzSd6fA78xcNrT4DBIOfto/lLmRXOoNBrdswApCkJn3Uwfw am83CNA1Igu6va7wQza4H4eDnEgGEScqQb/uMKmC9xVNj/MfAWbSxYcTRWhaTayWtl8P UqE4yXt8ilx4Asscukn3U4BGtJ1fpEJ4Yqc3ZctxzJLjDtqhytIWDLZW/u9NsSqBJULK c7WqwOOXu7UXya8fsmwtA4+bDcy6nXxL1lxGfQ2ZSkRF9fHkH3rJ5+fdf0BVGuVjuUWq Z0vg== X-Forwarded-Encrypted: i=1; AJvYcCUtUOBukieYZ+GstgXHNwT9/DqQQI5kGJu4vKPaprK/Pjms74AiXgCb4PYpute1gbYyaerVeOm0sm+MxBF3vbHr24Y30nH0nwDwHqf9 X-Gm-Message-State: AOJu0YyeK8Fawc90T54rPpD3LLXiKNL1hLrLoHkz9/9eku5P7HH/nSjM 9FgEEkmxA0l7mmGTDjMkm7tMex/+rhqLQZVwiP9YlW/oE2d/Y+s+QkUnag76/mGpQoC0E4hOBGq jErI6e13buw== X-Received: from szatan.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:2d83]) (user=panikiel job=sendgmr) by 2002:a05:6902:102c:b0:dc7:49a9:6666 with SMTP id x12-20020a056902102c00b00dc749a96666mr1825457ybt.3.1707743666187; Mon, 12 Feb 2024 05:14:26 -0800 (PST) Date: Mon, 12 Feb 2024 13:13:18 +0000 In-Reply-To: <20240212131323.2162161-1-panikiel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240212131323.2162161-1-panikiel@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240212131323.2162161-5-panikiel@google.com> Subject: [PATCH 4/9] lib: Move DisplayPort CRC functions to common lib From: " =?utf-8?q?Pawe=C5=82_Anikiel?= " To: airlied@gmail.com, akpm@linux-foundation.org, conor+dt@kernel.org, daniel@ffwll.ch, dinguyen@kernel.org, hverkuil-cisco@xs4all.nl, krzysztof.kozlowski+dt@linaro.org, maarten.lankhorst@linux.intel.com, mchehab@kernel.org, mripard@kernel.org, robh+dt@kernel.org, tzimmermann@suse.de Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, chromeos-krk-upstreaming@google.com, ribalda@chromium.org, " =?utf-8?q?Pawe?= =?utf-8?q?=C5=82_Anikiel?= " X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790699546655369303 X-GMAIL-MSGID: 1790699546655369303 The CRC functions found in drivers/gpu/drm/display/drm_dp_mst_topology.c may be useful for other non-DRM code that deals with DisplayPort, e.g. v4l2 drivers for DP receivers. Move these functions to /lib. Signed-off-by: Paweł Anikiel --- drivers/gpu/drm/display/Kconfig | 1 + drivers/gpu/drm/display/drm_dp_mst_topology.c | 76 ++---------------- include/linux/crc-dp.h | 10 +++ lib/Kconfig | 8 ++ lib/Makefile | 1 + lib/crc-dp.c | 78 +++++++++++++++++++ 6 files changed, 103 insertions(+), 71 deletions(-) create mode 100644 include/linux/crc-dp.h create mode 100644 lib/crc-dp.c diff --git a/drivers/gpu/drm/display/Kconfig b/drivers/gpu/drm/display/Kconfig index 09712b88a5b8..c615f50152f2 100644 --- a/drivers/gpu/drm/display/Kconfig +++ b/drivers/gpu/drm/display/Kconfig @@ -14,6 +14,7 @@ config DRM_DISPLAY_HELPER config DRM_DISPLAY_DP_HELPER bool depends on DRM_DISPLAY_HELPER + select CRC_DP help DRM display helpers for DisplayPort. diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c index f7c6b60629c2..ada1f90fa808 100644 --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -195,73 +196,6 @@ drm_dp_mst_rad_to_str(const u8 rad[8], u8 lct, char *out, size_t len) } /* sideband msg handling */ -static u8 drm_dp_msg_header_crc4(const uint8_t *data, size_t num_nibbles) -{ - u8 bitmask = 0x80; - u8 bitshift = 7; - u8 array_index = 0; - int number_of_bits = num_nibbles * 4; - u8 remainder = 0; - - while (number_of_bits != 0) { - number_of_bits--; - remainder <<= 1; - remainder |= (data[array_index] & bitmask) >> bitshift; - bitmask >>= 1; - bitshift--; - if (bitmask == 0) { - bitmask = 0x80; - bitshift = 7; - array_index++; - } - if ((remainder & 0x10) == 0x10) - remainder ^= 0x13; - } - - number_of_bits = 4; - while (number_of_bits != 0) { - number_of_bits--; - remainder <<= 1; - if ((remainder & 0x10) != 0) - remainder ^= 0x13; - } - - return remainder; -} - -static u8 drm_dp_msg_data_crc4(const uint8_t *data, u8 number_of_bytes) -{ - u8 bitmask = 0x80; - u8 bitshift = 7; - u8 array_index = 0; - int number_of_bits = number_of_bytes * 8; - u16 remainder = 0; - - while (number_of_bits != 0) { - number_of_bits--; - remainder <<= 1; - remainder |= (data[array_index] & bitmask) >> bitshift; - bitmask >>= 1; - bitshift--; - if (bitmask == 0) { - bitmask = 0x80; - bitshift = 7; - array_index++; - } - if ((remainder & 0x100) == 0x100) - remainder ^= 0xd5; - } - - number_of_bits = 8; - while (number_of_bits != 0) { - number_of_bits--; - remainder <<= 1; - if ((remainder & 0x100) != 0) - remainder ^= 0xd5; - } - - return remainder & 0xff; -} static inline u8 drm_dp_calc_sb_hdr_size(struct drm_dp_sideband_msg_hdr *hdr) { u8 size = 3; @@ -284,7 +218,7 @@ static void drm_dp_encode_sideband_msg_hdr(struct drm_dp_sideband_msg_hdr *hdr, (hdr->msg_len & 0x3f); buf[idx++] = (hdr->somt << 7) | (hdr->eomt << 6) | (hdr->seqno << 4); - crc4 = drm_dp_msg_header_crc4(buf, (idx * 2) - 1); + crc4 = crc_dp_msg_header(buf, (idx * 2) - 1); buf[idx - 1] |= (crc4 & 0xf); *len = idx; @@ -305,7 +239,7 @@ static bool drm_dp_decode_sideband_msg_hdr(const struct drm_dp_mst_topology_mgr len += ((buf[0] & 0xf0) >> 4) / 2; if (len > buflen) return false; - crc4 = drm_dp_msg_header_crc4(buf, (len * 2) - 1); + crc4 = crc_dp_msg_header(buf, (len * 2) - 1); if ((crc4 & 0xf) != (buf[len - 1] & 0xf)) { drm_dbg_kms(mgr->dev, "crc4 mismatch 0x%x 0x%x\n", crc4, buf[len - 1]); @@ -725,7 +659,7 @@ static void drm_dp_crc_sideband_chunk_req(u8 *msg, u8 len) { u8 crc4; - crc4 = drm_dp_msg_data_crc4(msg, len); + crc4 = crc_dp_msg_data(msg, len); msg[len] = crc4; } @@ -782,7 +716,7 @@ static bool drm_dp_sideband_append_payload(struct drm_dp_sideband_msg_rx *msg, if (msg->curchunk_idx >= msg->curchunk_len) { /* do CRC */ - crc4 = drm_dp_msg_data_crc4(msg->chunk, msg->curchunk_len - 1); + crc4 = crc_dp_msg_data(msg->chunk, msg->curchunk_len - 1); if (crc4 != msg->chunk[msg->curchunk_len - 1]) print_hex_dump(KERN_DEBUG, "wrong crc", DUMP_PREFIX_NONE, 16, 1, diff --git a/include/linux/crc-dp.h b/include/linux/crc-dp.h new file mode 100644 index 000000000000..b63435c82b96 --- /dev/null +++ b/include/linux/crc-dp.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_CRC_DP_H +#define _LINUX_CRC_DP_H + +#include + +u8 crc_dp_msg_header(const uint8_t *data, size_t num_nibbles); +u8 crc_dp_msg_data(const uint8_t *data, u8 number_of_bytes); + +#endif /* _LINUX_CRC_DP_H */ diff --git a/lib/Kconfig b/lib/Kconfig index 5ddda7c2ed9b..28f9f6cfec9f 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -171,6 +171,14 @@ config CRC_ITU_T the kernel tree does. Such modules that use library CRC ITU-T V.41 functions require M here. +config CRC_DP + tristate "CRC DisplayPort MST functions" + help + This option is provided for the case where no in-kernel-tree + modules require CRC DisplayPort MST functions, but a module built outside + the kernel tree does. Such modules that use library CRC DisplayPort MST + functions require M here. + config CRC32 tristate "CRC32/CRC32c functions" default y diff --git a/lib/Makefile b/lib/Makefile index 6b09731d8e61..e4d7ffa260b3 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -188,6 +188,7 @@ obj-$(CONFIG_CRC7) += crc7.o obj-$(CONFIG_LIBCRC32C) += libcrc32c.o obj-$(CONFIG_CRC8) += crc8.o obj-$(CONFIG_CRC64_ROCKSOFT) += crc64-rocksoft.o +obj-$(CONFIG_CRC_DP) += crc-dp.o obj-$(CONFIG_XXHASH) += xxhash.o obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o diff --git a/lib/crc-dp.c b/lib/crc-dp.c new file mode 100644 index 000000000000..95b58bc436d4 --- /dev/null +++ b/lib/crc-dp.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0 +#include + +/* + * Sideband MSG Header CRC + * Defined in DisplayPort 1.2 spec, section 2.11.3.1.9 + */ +u8 crc_dp_msg_header(const uint8_t *data, size_t num_nibbles) +{ + u8 bitmask = 0x80; + u8 bitshift = 7; + u8 array_index = 0; + int number_of_bits = num_nibbles * 4; + u8 remainder = 0; + + while (number_of_bits != 0) { + number_of_bits--; + remainder <<= 1; + remainder |= (data[array_index] & bitmask) >> bitshift; + bitmask >>= 1; + bitshift--; + if (bitmask == 0) { + bitmask = 0x80; + bitshift = 7; + array_index++; + } + if ((remainder & 0x10) == 0x10) + remainder ^= 0x13; + } + + number_of_bits = 4; + while (number_of_bits != 0) { + number_of_bits--; + remainder <<= 1; + if ((remainder & 0x10) != 0) + remainder ^= 0x13; + } + + return remainder; +} + +/* + * Sideband MSG Data CRC + * Defined in DisplayPort 1.2 spec, section 2.11.3.2.2 + */ +u8 crc_dp_msg_data(const uint8_t *data, u8 number_of_bytes) +{ + u8 bitmask = 0x80; + u8 bitshift = 7; + u8 array_index = 0; + int number_of_bits = number_of_bytes * 8; + u16 remainder = 0; + + while (number_of_bits != 0) { + number_of_bits--; + remainder <<= 1; + remainder |= (data[array_index] & bitmask) >> bitshift; + bitmask >>= 1; + bitshift--; + if (bitmask == 0) { + bitmask = 0x80; + bitshift = 7; + array_index++; + } + if ((remainder & 0x100) == 0x100) + remainder ^= 0xd5; + } + + number_of_bits = 8; + while (number_of_bits != 0) { + number_of_bits--; + remainder <<= 1; + if ((remainder & 0x100) != 0) + remainder ^= 0xd5; + } + + return remainder & 0xff; +} From patchwork Mon Feb 12 13:13:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Anikiel?= X-Patchwork-Id: 199766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2422991dyd; Mon, 12 Feb 2024 05:23:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWbXKNP1uskVHnFLqpcsgxSYSJoX+AGK2CCg8v/icRdDytk4Hb4Y+0/M08Pht7TZf+brv1 X-Received: by 2002:a0c:aada:0:b0:68c:cb57:72ba with SMTP id g26-20020a0caada000000b0068ccb5772bamr7276654qvb.29.1707744191546; Mon, 12 Feb 2024 05:23:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707744191; cv=pass; d=google.com; s=arc-20160816; b=ZVXa6cTdeAImye/WA7CIUxNNH7rQJhZOUYY95s7WdLLCrAD6Zci3esFSkQJWPyYauA CAClD06+Amw9fCOQqnZhmC4GYBu2Ip8hv6qb3F337e+Qnxc4H9e8qlkxBkM8p/Y0yZVC QqJN5Xyv3cNNZhbwX6QsVlrlshc1UFytQ/g/Ls/KHeJnFvMSlWX511Dzljzkr1q5wHt2 51lGSl32HnJgMwfWUvAakMbjT0RbOHKKMQS6QPYURViUVRSEGdMqntCKooHpO3M+NPfv vSrz9ZE5CPmwUZ6S+ETfPbzl8O1EH3xh6MAY1RmpQKOj/uAHiXi4LpFjmB3hR6BvNiUw 5iAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=RCSDKBlfQwozprcRZ3oUdFL3KROvOog8qplv+oCSSMA=; fh=D8uToZCTc2hi+Cwh0hSBZfNy8SX3YybPq2kCD9NF4lw=; b=dlbPaY7BC4uUlvIoGkuoYJYNq/69AxlJS4jo0HZl2NRpY2CmlUh+ugEiF/4qkukUDD vE8lv9wroGmY1NB7RX39b3keMho+xtKLi60CgUpl3vstD/Rr9k75PGEAbvWdTkPMCSfK csLD2Z1WdMrg764oRcfR9RzvXhQS3cTH/boHPcA7OHsVF586gQ10RdBEwtzZMFXLK9tK 56jJQotH+2VKuNWW0ogoABYG4/ZV+Vt9OV2ZEJKUgqvnN1gGmwPKhIE4xq4LPHibOhGm 00BfL1+z/HA+maNG99FQrTqLjATuSyGw6UQau+1CkMKec21w3GCKqfZQjAmC2ymS4/6q jOVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="YVfhB7/a"; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61642-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61642-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCUknPc/4OgPW0FZ60w3cv93TMR+/SGrGtw8JB/dATv11nhtmd8KapJ/lakkxOqp1RD7a57pebQIfjSwRMC1qcO23ZFP5g== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id js11-20020a0562142aab00b0068ccdb86eb6si356731qvb.4.2024.02.12.05.23.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:23:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61642-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="YVfhB7/a"; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61642-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61642-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 552961C219A2 for ; Mon, 12 Feb 2024 13:23:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E41764CB23; Mon, 12 Feb 2024 13:14:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YVfhB7/a" Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C9DC4655F for ; Mon, 12 Feb 2024 13:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743672; cv=none; b=emF/raWR4i0PCk0kWM/kXTenhF7FZoOr91frJr2N71ZhQ8qBwz0oDHwz5V64t/JHQc486GSt+q8iBHeb+BsE8zrXfElMPE9tvg33dhqi5t3uJzP1TS/DHap1ED3pkism5CDYkgsmVVPY9HseWn6+1zHL+ZcBwW5yWR6szlR+XKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743672; c=relaxed/simple; bh=NdMiTtGUPnnvJjmNHvIliTvDWwAYmwJMytgJIs+agUg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Pgxroxd4swnXc/K8f8CigsvgDx9z1U6koXgWoqtGTEpjfZtljIfPJ/fCSO5CcUDZnaD/aM27KhAbnAtRwTDHHQvn+4NCsfmq8hgevQbyhSEihwnr3mwGtuUUrNvMObBEWmuvGF6BIr5DTDxPD08z78Mykr05uwew9HwRVgSUrfU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=YVfhB7/a; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-410c65efe5bso6197395e9.1 for ; Mon, 12 Feb 2024 05:14:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707743669; x=1708348469; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=RCSDKBlfQwozprcRZ3oUdFL3KROvOog8qplv+oCSSMA=; b=YVfhB7/aqosYLzDMv7XIyEgioXA9DQeUzuQVwqlulfIBIJu17jMIearJxsFlTLsVpn cKEjvwF79MIvGnisoOYb4cF54JU6MK3jf6nyjlS5Gi1NGNvuxk5+GFQ9pJAR+GEJ/s9q 4w9dk71h7gBCEDPAkmRwZxkgA06aQ0YLQEUgAnzwUKqKF/R08p+pPbxU9ph4XoI1K/HK F0HZP81F5FykYjGmvj7A7hxB8hk/fcJHpvFIKKicXzE/HIAFk65oXCyIeHH8HZP/f1if qUjVknv5+Rk0nDmKPIb0rThCsKtfahci4z3sHMz0ZN86j0VvZ+JWV//E7e9wns0m04Pi ZigA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707743669; x=1708348469; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=RCSDKBlfQwozprcRZ3oUdFL3KROvOog8qplv+oCSSMA=; b=dAHrLdwUHIrmQ5UU+Lu+m9jxpI8j2pBh5UB0lI6UyaCGbawq572hUYiFJkqDtNm3Vj 6maYQDW3ILYVpo4zTnfWz8b3nbF/zpxNmhK0UBnOqKOT9+qUVKO8o9vqXmQ1i594Z+TD sBw/7vNJaEb/HzjDiCiLy+EK0h7Dh3MzSLu0xzgUdYafixkL8IAMNEp2GP8v7aTVZr/p 5v3l8u0uPV0SVutjPkgmAetvAez85cbBTRPyx3eXcNdcQGznu4ObuOHcvk9Y9WGbXl+E 0q1xul7ctfyy70niafwxc2+hktFKT5LVL91U0Kpd/AEqCdj2wEg9qt00Y2BfxGhpYnIo EQLQ== X-Gm-Message-State: AOJu0YybfgCM/Jhad81edR4AaZVc8i9rTS/a7jrzSxGw5pyLmMBEAhQi U90E2D9VZqQKbXMFScluGWSBsgz/wCSKy+Gds9AfxMSF1QMSI1I8UvXxAvsPm61+eKwSCWzI7cp L17YCbOn6cw== X-Received: from szatan.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:2d83]) (user=panikiel job=sendgmr) by 2002:a05:600c:6002:b0:410:e190:b1b3 with SMTP id az2-20020a05600c600200b00410e190b1b3mr5577wmb.4.1707743668739; Mon, 12 Feb 2024 05:14:28 -0800 (PST) Date: Mon, 12 Feb 2024 13:13:19 +0000 In-Reply-To: <20240212131323.2162161-1-panikiel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240212131323.2162161-1-panikiel@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240212131323.2162161-6-panikiel@google.com> Subject: [PATCH 5/9] drm/display: Add mask definitions for DP_PAYLOAD_ALLOCATE_* registers From: " =?utf-8?q?Pawe=C5=82_Anikiel?= " To: airlied@gmail.com, akpm@linux-foundation.org, conor+dt@kernel.org, daniel@ffwll.ch, dinguyen@kernel.org, hverkuil-cisco@xs4all.nl, krzysztof.kozlowski+dt@linaro.org, maarten.lankhorst@linux.intel.com, mchehab@kernel.org, mripard@kernel.org, robh+dt@kernel.org, tzimmermann@suse.de Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, chromeos-krk-upstreaming@google.com, ribalda@chromium.org, " =?utf-8?q?Pawe?= =?utf-8?q?=C5=82_Anikiel?= " X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790699573633785545 X-GMAIL-MSGID: 1790699573633785545 Each of these registers contains a single value, but not the entire 8 bits: DP_PAYLOAD_ALLOCATE_SET - Bit 7 Reserved DP_PAYLOAD_ALLOCATE_START_TIME_SLOT - Bits 7:6 Reserved DP_PAYLOAD_ALLOCATE_TIME_SLOT_COUNT - Bits 7:6 Reserved Add definitions to properly mask off values read from these registers. Signed-off-by: Paweł Anikiel --- include/drm/display/drm_dp.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/drm/display/drm_dp.h b/include/drm/display/drm_dp.h index 3731828825bd..9dee30190f14 100644 --- a/include/drm/display/drm_dp.h +++ b/include/drm/display/drm_dp.h @@ -733,8 +733,13 @@ # define DP_PANEL_REPLAY_SU_ENABLE (1 << 6) #define DP_PAYLOAD_ALLOCATE_SET 0x1c0 -#define DP_PAYLOAD_ALLOCATE_START_TIME_SLOT 0x1c1 -#define DP_PAYLOAD_ALLOCATE_TIME_SLOT_COUNT 0x1c2 +# define DP_PAYLOAD_ALLOCATE_SET_MASK 0x7f + +#define DP_PAYLOAD_ALLOCATE_START_TIME_SLOT 0x1c1 +# define DP_PAYLOAD_ALLOCATE_START_TIME_SLOT_MASK 0x3f + +#define DP_PAYLOAD_ALLOCATE_TIME_SLOT_COUNT 0x1c2 +# define DP_PAYLOAD_ALLOCATE_TIME_SLOT_COUNT_MASK 0x3f /* Link/Sink Device Status */ #define DP_SINK_COUNT 0x200 From patchwork Mon Feb 12 13:13:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Anikiel?= X-Patchwork-Id: 199775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2425149dyd; Mon, 12 Feb 2024 05:26:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVVo2A7vprXUmcbL3IwyMiL+sZypph+0gfi7JZdmpEu+RpSD7eaz6F/4p0o/bNnTf9J4v8+fH3GEegEZXIF5XnMio+J1g== X-Google-Smtp-Source: AGHT+IEXng3VurxXnEZ7P5S9zVz/SWgwDQVGg4eN2xXOCLDBGS0mi/iyBwL4dP1BQa6nReW8AQAM X-Received: by 2002:a05:620a:1a0e:b0:787:1522:69d8 with SMTP id bk14-20020a05620a1a0e00b00787152269d8mr599880qkb.51.1707744411925; Mon, 12 Feb 2024 05:26:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707744411; cv=pass; d=google.com; s=arc-20160816; b=LspiR4fUFI5B8/ORMAOQc4r1bVggzRCbUo4PSCMG9oIMivAA/q2/Juh6MEqRtPj1M4 U4XudHONyJs2zz+jsj+aCyBDjfLymT3EJsARP7Xs6mvxNOEETRaTjsQiZxJK5vKeKbSW Nhw3h1D1CQVM7LIZN2vWj3DiuTHLTA3idsUg9viMEiLZNAQUTT0MvjfbRDsQSYxxPKnp GgurapQJfJcXNIKnM6ZGYc8NudLaY06VlH/XfPLGVhqJmDN46z+/J+cj9NDHIqtoFKI0 HuKywgJWrSc4CO5QcOaaAm8EgdQianUiPFaaxys5xP3osUC5tmT4W3vBJcTvkO062cvo 6ELg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=5JQuOjkadeaIseP1y8XgxyLtmJI2UqxJB/QsHzUuQdw=; fh=VHPUs2dxRg8OkNkzOYPRwcFJBHhiS2J6SlUgAWmiAOk=; b=WFgSeZp/26iJpNxjptGd164OKUUi5QJRG5G2P7zZ1dwMChzYPVOnmIGAohamqO2hL5 cEls5cWeLkQezMWH8wRZNtx5gdd+7Oh0i1KvqsmCcGvpFxx+OUALTY6H6MNK5/U+sE/s vwjDUqx67hTrXh9AhZlip568XqjMDZhH97w/vM/iF9v8up5D9VflpaLlxcYIaUI9C83X jBrd7nw65U6Nn68ApkoBJpwSZ16sdgS4jCzPUUCYjYmq+Tr7ju25ihLTmZABQM5klANP FMSEtQWdSFP4N4TS9DtHfzYFZE0GBlfTC8drPnCGchRVEqVHRrkiriHGgx8ERrd6PUQ3 lJjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=FyHxDqXJ; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61646-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61646-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCU3AwnjYHKJn4U2AUXLcEng3zCnmuBB5S1SNomeXjeYrff8Svs/LSxzQL9Y5CJ2IwoCL+NsRy/JSl3UVlN3RDO4hU8K7w== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d12-20020a37c40c000000b007858a94dccesi5687993qki.504.2024.02.12.05.26.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:26:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61646-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=FyHxDqXJ; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61646-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61646-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 957CB1C21583 for ; Mon, 12 Feb 2024 13:26:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E81B51C3A; Mon, 12 Feb 2024 13:14:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FyHxDqXJ" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D5B147F45 for ; Mon, 12 Feb 2024 13:14:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743677; cv=none; b=dWVncapZOhCukz9M+A4+hrTAozapQrZhzjUND2g5LDf0IKKS13r/V3UB/4KpzKV9VwO9TF7IPSHUaL1HxvnG29oDHwVf1ex7WVs32fNQ+jaea1OEbZ5YGINzsfN5+eZw6BNDQyu8zIVZ39OgLWLKeO5ceyPzWnKyqH+U0shiDTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743677; c=relaxed/simple; bh=Y+NhLpC5fWdEhhIahQYyu6wRDfXGE9ViumJmvddIeKY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=NtGv2ulu4Ir4hYXBzMPekOiQ95KlSDSUDno13ifFkJqJC4POIoPgn94Zv/YebC455DSNB59MTouHvDx0Rsi13bKMZkLM403o8mJb/XULrW7z5riA6/5iIax7j2nd67gjp4n88K6EIt0nOYQVdgEwvkZX0IW8xM1iexRBNFCTGRs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=FyHxDqXJ; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dcbc447ddfeso222426276.1 for ; Mon, 12 Feb 2024 05:14:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707743671; x=1708348471; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=5JQuOjkadeaIseP1y8XgxyLtmJI2UqxJB/QsHzUuQdw=; b=FyHxDqXJkQqVxqD5iYnJtu7ZqvgpBRxKCHwwElke0h0BTxo0LAXNqqS4z8+bKbmyOh nMOWDzPUuRjdlE5B69d6fFGVcpUpChIJCBxeQTVieDfgUv73IdDWELEgnM5qnAcHJBKM jxYZkX11xL42+aojCj3YLdPp/FVqyZfL/gkHSQ7mRj/IDbjEsJiSn3Iq+qlA1acLKtxm gvLCEQXhdSqZtnxYKZ/AXf3BxyWSRnv3ikhDWetXhFkQT/T2z6pJowdD/qc9C4gHaSUk CtRjw8aKt22oZGuZiM5hDEwa0EUCdnG3hK03TN95neigc3SSwIAoQanzY7b5NhUkG+q8 n/dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707743671; x=1708348471; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=5JQuOjkadeaIseP1y8XgxyLtmJI2UqxJB/QsHzUuQdw=; b=IsoeyPV1eUFsEdjNX8gtTHpsx53YTd7ommLcuOudeYc3ZdVTDroHvHdBUSb4l6GyII nPRPYXwUaBfdq1vBPpVaSvI6M20MukWztWnl9stN5qO/6NYr2baAdRazIPvtDoxdjJA5 kRX14vEhiBcBmLa4a4Pb31/FSPwOZuo8cZIMswUtrn6cJcNkHDtYU3wI1pa/TJlzyCBd VyCNwcKVSl8Zr+NDE/Q14nBIXAk93ywzlgp0U08UcZGhb5l6mHwZYqOJe5EUCeOEhBzj +5toLxrA5pcNeohKFqFdmc0q8Ei4hpsmhwzOfRtYxcZMy6YWkPPBoaSVW674fVDHXbn8 2DAA== X-Forwarded-Encrypted: i=1; AJvYcCVun7ik8o7vQhyZGBDkQqwjKbuGaLxUhtjtwBiAj0QtXOvxJwQgSiJdvRUDZJHaTIcvhfTKmmawqBhu9w3VGIeG/c9MuDXVJ63a6/SF X-Gm-Message-State: AOJu0YzKzfYH99ie/jWwg/9poWoVJgN0OirucbzeJXVBZyg298ar2oFq tRkzluzXIycg+dwYEYBlbIAk3xP7lwy1nEaZ14HrRwTqWWepjeIp//BMbB1Rv1RVCAAW8frxTUt Ak2CZf7exgQ== X-Received: from szatan.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:2d83]) (user=panikiel job=sendgmr) by 2002:a05:6902:1007:b0:dc6:e20f:80cb with SMTP id w7-20020a056902100700b00dc6e20f80cbmr289894ybt.3.1707743671308; Mon, 12 Feb 2024 05:14:31 -0800 (PST) Date: Mon, 12 Feb 2024 13:13:20 +0000 In-Reply-To: <20240212131323.2162161-1-panikiel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240212131323.2162161-1-panikiel@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240212131323.2162161-7-panikiel@google.com> Subject: [PATCH 6/9] media: intel: Add Displayport RX IP driver From: " =?utf-8?q?Pawe=C5=82_Anikiel?= " To: airlied@gmail.com, akpm@linux-foundation.org, conor+dt@kernel.org, daniel@ffwll.ch, dinguyen@kernel.org, hverkuil-cisco@xs4all.nl, krzysztof.kozlowski+dt@linaro.org, maarten.lankhorst@linux.intel.com, mchehab@kernel.org, mripard@kernel.org, robh+dt@kernel.org, tzimmermann@suse.de Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, chromeos-krk-upstreaming@google.com, ribalda@chromium.org, " =?utf-8?q?Pawe?= =?utf-8?q?=C5=82_Anikiel?= " X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790699804559437779 X-GMAIL-MSGID: 1790699804559437779 Add driver for the Intel DisplayPort RX FPGA IP Signed-off-by: Paweł Anikiel --- drivers/media/platform/intel/Kconfig | 12 + drivers/media/platform/intel/Makefile | 1 + drivers/media/platform/intel/intel-dprx.c | 2171 +++++++++++++++++++++ 3 files changed, 2184 insertions(+) create mode 100644 drivers/media/platform/intel/intel-dprx.c diff --git a/drivers/media/platform/intel/Kconfig b/drivers/media/platform/intel/Kconfig index 724e80a9086d..eafcd47cce68 100644 --- a/drivers/media/platform/intel/Kconfig +++ b/drivers/media/platform/intel/Kconfig @@ -12,3 +12,15 @@ config VIDEO_PXA27x select V4L2_FWNODE help This is a v4l2 driver for the PXA27x Quick Capture Interface + +config VIDEO_INTEL_DPRX + tristate "Intel DisplayPort RX IP driver" + depends on V4L_PLATFORM_DRIVERS + depends on VIDEO_DEV + select V4L2_FWNODE + select CRC_DP + help + v4l2 subdev driver for Intel Displayport receiver FPGA IP. + It is a part of the DisplayPort Intel FPGA IP Core. + It implements a DisplayPort 1.4 receiver capable of HBR3 + video capture and Multi-Stream Transport. diff --git a/drivers/media/platform/intel/Makefile b/drivers/media/platform/intel/Makefile index 7e8889cbd2df..f571399f5aa8 100644 --- a/drivers/media/platform/intel/Makefile +++ b/drivers/media/platform/intel/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o +obj-$(CONFIG_VIDEO_INTEL_DPRX) += intel-dprx.o diff --git a/drivers/media/platform/intel/intel-dprx.c b/drivers/media/platform/intel/intel-dprx.c new file mode 100644 index 000000000000..88998dc218c1 --- /dev/null +++ b/drivers/media/platform/intel/intel-dprx.c @@ -0,0 +1,2171 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2023-2024 Google LLC. + * Author: Paweł Anikiel + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DPRX_MAX_EDID_BLOCKS 4 +#define DPRX_MAX_LANE_COUNT 4 +#define DPRX_MAX_LINK_RATE DP_LINK_BW_8_1 + +/* DPRX registers */ + +#define DPRX_RX_CONTROL 0x000 +#define DPRX_RX_CONTROL_LINK_RATE_SHIFT 16 +#define DPRX_RX_CONTROL_LINK_RATE_MASK 0xff +#define DPRX_RX_CONTROL_RECONFIG_LINKRATE 13 +#define DPRX_RX_CONTROL_TP_SHIFT 8 +#define DPRX_RX_CONTROL_TP_MASK 0x7 +#define DPRX_RX_CONTROL_SCRAMBLER_DISABLE 7 +#define DPRX_RX_CONTROL_CHANNEL_CODING_SHIFT 5 +#define DPRX_RX_CONTROL_CHANNEL_CODING_8B10B 0x1 +#define DPRX_RX_CONTROL_LANE_COUNT_SHIFT 0 +#define DPRX_RX_CONTROL_LANE_COUNT_MASK 0x1f + +#define DPRX_RX_STATUS 0x001 +#define DPRX_RX_STATUS_INTERLANE_ALIGN 8 +#define DPRX_RX_STATUS_SYM_LOCK_SHIFT 4 +#define DPRX_RX_STATUS_SYM_LOCK(i) (4 + i) +#define DPRX_RX_STATUS_CR_LOCK_SHIFT 0 +#define DPRX_RX_STATUS_CR_LOCK(i) (0 + i) + +#define DPRX_MSA_HTOTAL(i) (0x022 + 0x20 * (i)) +#define DPRX_MSA_VTOTAL(i) (0x023 + 0x20 * (i)) +#define DPRX_MSA_HSP(i) (0x024 + 0x20 * (i)) +#define DPRX_MSA_HSW(i) (0x025 + 0x20 * (i)) +#define DPRX_MSA_HSTART(i) (0x026 + 0x20 * (i)) +#define DPRX_MSA_VSTART(i) (0x027 + 0x20 * (i)) +#define DPRX_MSA_VSP(i) (0x028 + 0x20 * (i)) +#define DPRX_MSA_VSW(i) (0x029 + 0x20 * (i)) +#define DPRX_MSA_HWIDTH(i) (0x02a + 0x20 * (i)) +#define DPRX_MSA_VHEIGHT(i) (0x02b + 0x20 * (i)) +#define DPRX_VBID(i) (0x02f + 0x20 * (i)) +#define DPRX_VBID_MSA_LOCK 7 + +#define DPRX_MST_CONTROL1 0x0a0 +#define DPRX_MST_CONTROL1_VCPTAB_UPD_FORCE 31 +#define DPRX_MST_CONTROL1_VCPTAB_UPD_REQ 30 +#define DPRX_MST_CONTROL1_VCP_ID_SHIFT(i) (4 + 4 * (i)) +#define DPRX_MST_CONTROL1_VCP_IDS_SHIFT 4 +#define DPRX_MST_CONTROL1_VCP_IDS_MASK 0xffff +#define DPRX_MST_CONTROL1_MST_EN 0 + +#define DPRX_MST_STATUS1 0x0a1 +#define DPRX_MST_STATUS1_VCPTAB_ACT_ACK 30 + +#define DPRX_MST_VCPTAB(i) (0x0a2 + i) + +#define DPRX_AUX_CONTROL 0x100 +#define DPRX_AUX_CONTROL_IRQ_EN 8 +#define DPRX_AUX_CONTROL_TX_STROBE 7 +#define DPRX_AUX_CONTROL_LENGTH_SHIFT 0 +#define DPRX_AUX_CONTROL_LENGTH_MASK 0x1f + +#define DPRX_AUX_STATUS 0x101 +#define DPRX_AUX_STATUS_MSG_READY 31 +#define DPRX_AUX_STATUS_READY_TO_TX 30 + +#define DPRX_AUX_COMMAND 0x102 + +#define DPRX_AUX_HPD 0x119 +#define DPRX_AUX_HPD_IRQ 12 +#define DPRX_AUX_HPD_EN 11 + +/* IRQ registers */ + +#define DPRX_IRQ_MASK 0x8 +#define DPRX_IRQ_CLR 0xc +#define DPRX_IRQ_AUX 0x1 + +/* DDC defines */ + +#define DDC_EDID_ADDR 0x50 +#define DDC_SEGMENT_ADDR 0x30 + +struct dprx_training_control { + u8 volt_swing; + u8 pre_emph; + bool max_swing; + bool max_pre_emph; +}; + +struct dprx_sink { + u8 edid[128 * DPRX_MAX_EDID_BLOCKS]; + int blocks; + int offset; + int segment; +}; + +struct msg_transaction_rxbuf { + u8 buf[256]; + int len; +}; + +struct msg_transaction_txbuf { + u8 buf[256]; + int len; + int written; +}; + +struct msg_transaction_meta { + u8 lct; + u8 rad[8]; + bool seqno; +}; + +struct dprx { + struct device *dev; + void __iomem *iobase; + void __iomem *iobase_irq; + + struct v4l2_subdev subdev; + struct media_pad pads[4]; + + struct dprx_sink sinks[4]; + + bool has_mst; + u8 sink_count; + + u8 guid[16]; + + struct dprx_training_control training_control[4]; + + u8 payload_allocate_set; + u8 payload_allocate_start_time_slot; + u8 payload_allocate_time_slot_count; + u8 payload_table[64]; + u8 payload_table_updated; + + u8 payload_id[4]; + u32 payload_pbn[4]; + u32 payload_pbn_total; + + u8 irq_vector; + + u8 down_req_buf[48]; + u8 down_rep_buf[48]; + + struct msg_transaction_rxbuf mt_rxbuf[2]; + struct msg_transaction_txbuf mt_txbuf[2]; + struct msg_transaction_meta mt_meta[2]; + bool mt_seqno; + bool mt_pending; + bool down_rep_pending; + + spinlock_t lock; +}; + +struct aux_buf { + u8 data[20]; + int len; +}; + +struct aux_msg { + u8 cmd; + u32 addr; + u8 len; + u8 data[16]; +}; + +struct sideband_msg { + u8 lct; + u8 lcr; + u8 rad[8]; + bool broadcast; + bool path_msg; + bool somt; + bool eomt; + bool seqno; + + u8 body[48]; + u8 body_len; +}; + +static void dprx_write(struct dprx *dprx, int addr, u32 val) +{ + writel(val, dprx->iobase + (addr * 4)); +} + +static u32 dprx_read(struct dprx *dprx, int addr) +{ + return readl(dprx->iobase + (addr * 4)); +} + +static void dprx_set_irq(struct dprx *dprx, int val) +{ + u32 reg; + + reg = dprx_read(dprx, DPRX_AUX_CONTROL); + reg |= ~(1 << DPRX_AUX_CONTROL_IRQ_EN); + reg |= val << DPRX_AUX_CONTROL_IRQ_EN; + dprx_write(dprx, DPRX_AUX_CONTROL, reg); +} + +static void dprx_set_hpd(struct dprx *dprx, int val) +{ + u32 reg; + + reg = dprx_read(dprx, DPRX_AUX_HPD); + reg &= ~(1 << DPRX_AUX_HPD_EN); + reg |= val << DPRX_AUX_HPD_EN; + dprx_write(dprx, DPRX_AUX_HPD, reg); +} + +static void dprx_pulse_hpd(struct dprx *dprx) +{ + u32 reg; + + reg = dprx_read(dprx, DPRX_AUX_HPD); + reg |= 1 << DPRX_AUX_HPD_IRQ; + dprx_write(dprx, DPRX_AUX_HPD, reg); +} + +static void dprx_clear_vc_payload_table(struct dprx *dprx) +{ + u32 reg; + int i; + + memset(dprx->payload_table, 0, sizeof(dprx->payload_table)); + + for (i = 0; i < 8; i++) + dprx_write(dprx, DPRX_MST_VCPTAB(i), 0); + + reg = dprx_read(dprx, DPRX_MST_CONTROL1); + reg &= ~(DPRX_MST_CONTROL1_VCP_IDS_MASK << DPRX_MST_CONTROL1_VCP_IDS_SHIFT); + reg |= 1 << DPRX_MST_CONTROL1_VCPTAB_UPD_FORCE; + dprx_write(dprx, DPRX_MST_CONTROL1, reg); +} + +static void dprx_set_vc_payload_table(struct dprx *dprx) +{ + int i, j; + u32 reg; + u8 val; + + /* + * The IP core only accepts VC payload IDs of 1-4. Thus, we need to + * remap the 1-63 range allowed by DisplayPort into 1-4. However, some + * hosts first set the VC payload table and then allocate the VC + * payload IDs, which means we can't remap the range immediately. + * + * It is probably possible to force a VC payload table update (without + * waiting for a ACT trigger) when the IDs change, but for now we just + * ignore IDs higher than 4. + */ + for (i = 0; i < 8; i++) { + reg = 0; + for (j = 0; j < 8; j++) { + val = dprx->payload_table[i*8+j]; + if (val <= 4) + reg |= val << (j * 4); + } + dprx_write(dprx, DPRX_MST_VCPTAB(i), reg); + } + + reg = dprx_read(dprx, DPRX_MST_CONTROL1); + reg |= 1 << DPRX_MST_CONTROL1_VCPTAB_UPD_REQ; + dprx_write(dprx, DPRX_MST_CONTROL1, reg); +} + +static void dprx_set_vc_ids(struct dprx *dprx) +{ + u32 reg; + int i; + + reg = dprx_read(dprx, DPRX_MST_CONTROL1); + reg &= ~(DPRX_MST_CONTROL1_VCP_IDS_MASK << DPRX_MST_CONTROL1_VCP_IDS_SHIFT); + for (i = 0; i < dprx->sink_count; i++) { + if (dprx->payload_id[i] <= 4) + reg |= dprx->payload_id[i] << DPRX_MST_CONTROL1_VCP_ID_SHIFT(i); + } + dprx_write(dprx, DPRX_MST_CONTROL1, reg); +} + +static void dprx_allocate_vc_payload(struct dprx *dprx, u8 start, u8 count, u8 id) +{ + if (count > sizeof(dprx->payload_table) - start) + count = sizeof(dprx->payload_table) - start; + memset(dprx->payload_table + start, id, count); +} + +static void dprx_deallocate_vc_payload(struct dprx *dprx, int start, u8 id) +{ + u8 to = start; + u8 i; + + for (i = start; i < sizeof(dprx->payload_table); i++) { + if (dprx->payload_table[i] == id) + dprx->payload_table[i] = 0; + else + dprx->payload_table[to++] = dprx->payload_table[i]; + } +} + +static u32 dprx_full_pbn(struct dprx *dprx) +{ + u32 reg; + u32 lane_count; + u32 link_rate; + + if ((dprx_read(dprx, DPRX_RX_STATUS) >> DPRX_RX_STATUS_INTERLANE_ALIGN) & 1) { + /* link training done - get current bandwidth */ + reg = dprx_read(dprx, DPRX_RX_CONTROL); + lane_count = (reg >> DPRX_RX_CONTROL_LANE_COUNT_SHIFT) & + DPRX_RX_CONTROL_LANE_COUNT_MASK; + link_rate = (reg >> DPRX_RX_CONTROL_LINK_RATE_SHIFT) & + DPRX_RX_CONTROL_LINK_RATE_MASK; + } else { + /* link training not done - get max bandwidth */ + lane_count = DPRX_MAX_LANE_COUNT; + link_rate = DPRX_MAX_LINK_RATE; + } + + return lane_count * link_rate * 32; +} + +static int dprx_port_number_to_sink_idx(struct dprx *dprx, u8 port_number) +{ + /* check if port number is valid */ + if (port_number < DP_MST_LOGICAL_PORT_0 || + port_number >= DP_MST_LOGICAL_PORT_0 + dprx->sink_count) + return -1; + + return port_number - DP_MST_LOGICAL_PORT_0; +} + +static bool dprx_adjust_needed(struct dprx *dprx) +{ + u32 control; + u32 status; + u32 lane_count; + u32 lane_count_mask; + u32 pattern; + + control = dprx_read(dprx, DPRX_RX_CONTROL); + status = dprx_read(dprx, DPRX_RX_STATUS); + + pattern = (control >> DPRX_RX_CONTROL_TP_SHIFT) & DPRX_RX_CONTROL_TP_MASK; + lane_count = (control >> DPRX_RX_CONTROL_LANE_COUNT_SHIFT) & + DPRX_RX_CONTROL_LANE_COUNT_MASK; + lane_count_mask = (1 << lane_count) - 1; + + if (pattern == 0) { + /* link training not in progress */ + return false; + } else if (pattern == 1) { + /* link training CR phase - check CR lock */ + return (~status) & (lane_count_mask << DPRX_RX_STATUS_CR_LOCK_SHIFT); + } + /* link training EQ phase - check synbol lock and interlane align */ + return (~status) & (lane_count_mask << DPRX_RX_STATUS_SYM_LOCK_SHIFT | + 1 << DPRX_RX_STATUS_INTERLANE_ALIGN); +} + +/* + * Return next allowed voltage swing, and pre-emphasis pair. + * DisplayPort 1.2 spec, section 3.1.5.2 + */ +static void dprx_training_control_next(struct dprx_training_control *ctl, + u8 *next_volt_swing, u8 *next_pre_emph) +{ + u8 volt_swing = ctl->volt_swing; + u8 pre_emph = ctl->pre_emph; + + pre_emph++; + if (pre_emph > 2) { + volt_swing++; + pre_emph = 0; + } + + if (volt_swing > 2 || (volt_swing == 2 && pre_emph == 2)) { + volt_swing = 0; + pre_emph = 0; + } + + *next_volt_swing = volt_swing; + *next_pre_emph = pre_emph; +} + +static int dprx_i2c_read(struct dprx_sink *sink, u8 addr, u8 *buf, int len) +{ + int offset; + + if (len == 0) + return 0; + + switch (addr) { + case DDC_EDID_ADDR: + offset = sink->offset + sink->segment * 256; + if (len + offset > sink->blocks * 128) + return -1; + memcpy(buf, sink->edid + offset, len); + sink->offset += len; + break; + case DDC_SEGMENT_ADDR: + if (len > 1) + return -1; + buf[0] = sink->segment; + break; + default: + return -1; + } + + return 0; +} + +static int dprx_i2c_write(struct dprx_sink *sink, u8 addr, u8 *buf, int len) +{ + if (len == 0) + return 0; + if (len > 1) + return -1; + + switch (addr) { + case DDC_EDID_ADDR: + sink->offset = buf[0]; + break; + case DDC_SEGMENT_ADDR: + sink->segment = buf[0]; + break; + default: + return -1; + } + + return 0; +} + +static void dprx_i2c_stop(struct dprx_sink *sink) +{ + sink->segment = 0; +} + +static void dprx_write_nak(struct dprx *dprx, + struct drm_dp_sideband_msg_reply_body *rep, + u8 req_type, u8 reason) +{ + rep->reply_type = DP_SIDEBAND_REPLY_NAK; + rep->req_type = req_type; + + memcpy(rep->u.nak.guid, dprx->guid, sizeof(dprx->guid)); + rep->u.nak.reason = reason; + rep->u.nak.nak_data = 0; +} + +static void dprx_execute_link_address(struct dprx *dprx, + struct drm_dp_sideband_msg_req_body *req, + struct drm_dp_sideband_msg_reply_body *rep) +{ + struct drm_dp_link_address_ack_reply *link_address = &rep->u.link_addr; + struct drm_dp_link_addr_reply_port *port = link_address->ports; + int i; + + rep->reply_type = DP_SIDEBAND_REPLY_ACK; + rep->req_type = DP_LINK_ADDRESS; + + memcpy(link_address->guid, dprx->guid, sizeof(dprx->guid)); + link_address->nports = dprx->sink_count + 1; + + /* Port 0: input (physical) */ + port->input_port = true; + port->peer_device_type = DP_PEER_DEVICE_SOURCE_OR_SST; + port->port_number = 0; + port->mcs = false; + port->ddps = true; + port++; + + for (i = 0; i < dprx->sink_count; i++) { + /* Port 8 + n: internal sink number n (logical) */ + port->input_port = false; + port->port_number = DP_MST_LOGICAL_PORT_0 + i; + port->mcs = false; + if (dprx->sinks[i].blocks > 0) { + port->peer_device_type = DP_PEER_DEVICE_SST_SINK; + port->ddps = true; + } else { + port->peer_device_type = DP_PEER_DEVICE_NONE; + port->ddps = false; + } + port->legacy_device_plug_status = false; + port->dpcd_revision = 0; + memset(port->peer_guid, 0, 16); + port->num_sdp_streams = 0; + port->num_sdp_stream_sinks = 0; + port++; + } +} + +static void dprx_execute_connection_status_notify(struct dprx *dprx, + struct drm_dp_sideband_msg_req_body *req, + struct drm_dp_sideband_msg_reply_body *rep) +{ + rep->reply_type = DP_SIDEBAND_REPLY_ACK; + rep->req_type = DP_CONNECTION_STATUS_NOTIFY; +} + +static void dprx_execute_enum_path_resources(struct dprx *dprx, + struct drm_dp_sideband_msg_req_body *req, + struct drm_dp_sideband_msg_reply_body *rep) +{ + u32 full_pbn = dprx_full_pbn(dprx); + + rep->reply_type = DP_SIDEBAND_REPLY_ACK; + rep->req_type = DP_ENUM_PATH_RESOURCES; + + rep->u.path_resources.port_number = req->u.port_num.port_number; + rep->u.path_resources.fec_capable = false; + rep->u.path_resources.full_payload_bw_number = full_pbn; + if (dprx->payload_pbn_total > full_pbn) + rep->u.path_resources.avail_payload_bw_number = 0; + else + rep->u.path_resources.avail_payload_bw_number = full_pbn - dprx->payload_pbn_total; +} + +static void dprx_execute_allocate_payload(struct dprx *dprx, + struct drm_dp_sideband_msg_req_body *req, + struct drm_dp_sideband_msg_reply_body *rep) +{ + struct drm_dp_allocate_payload *a_req = &req->u.allocate_payload; + struct drm_dp_allocate_payload_ack_reply *a_rep = &rep->u.allocate_payload; + int sink_idx; + + sink_idx = dprx_port_number_to_sink_idx(dprx, a_req->port_number); + if (sink_idx == -1) { + dprx_write_nak(dprx, rep, req->req_type, DP_NAK_BAD_PARAM); + return; + } + + if (a_req->vcpi == 0) { + dprx_write_nak(dprx, rep, req->req_type, DP_NAK_BAD_PARAM); + return; + } + + if (a_req->pbn > 0) { + if (dprx->payload_pbn[sink_idx] == 0) { + /* New payload ID */ + dprx->payload_id[sink_idx] = a_req->vcpi; + } else if (dprx->payload_id[sink_idx] != a_req->vcpi) { + /* At most one payload ID is allowed per sink */ + dprx_write_nak(dprx, rep, req->req_type, DP_NAK_ALLOCATE_FAIL); + return; + } + } + WARN_ON_ONCE(dprx->payload_pbn_total < dprx->payload_pbn[sink_idx]); + dprx->payload_pbn_total -= dprx->payload_pbn[sink_idx]; + dprx->payload_pbn_total += a_req->pbn; + dprx->payload_pbn[sink_idx] = a_req->pbn; + + dprx_set_vc_ids(dprx); + + rep->reply_type = DP_SIDEBAND_REPLY_ACK; + rep->req_type = DP_ALLOCATE_PAYLOAD; + + a_rep->port_number = a_req->port_number; + a_rep->vcpi = a_req->vcpi; + a_rep->allocated_pbn = a_req->pbn; +} + +static void dprx_execute_clear_payload_id_table(struct dprx *dprx, + struct drm_dp_sideband_msg_req_body *req, + struct drm_dp_sideband_msg_reply_body *rep) +{ + rep->reply_type = DP_SIDEBAND_REPLY_ACK; + rep->req_type = DP_CLEAR_PAYLOAD_ID_TABLE; + + dprx_clear_vc_payload_table(dprx); +} + +static void dprx_execute_remote_dpcd_read(struct dprx *dprx, + struct drm_dp_sideband_msg_req_body *req, + struct drm_dp_sideband_msg_reply_body *rep) +{ + struct drm_dp_remote_dpcd_read *read_req = &req->u.dpcd_read; + struct drm_dp_remote_dpcd_read_ack_reply *read_rep = &rep->u.remote_dpcd_read_ack; + + rep->reply_type = DP_SIDEBAND_REPLY_ACK; + rep->req_type = DP_REMOTE_DPCD_READ; + + read_rep->port_number = read_req->port_number; + read_rep->num_bytes = read_req->num_bytes; + memset(read_rep->bytes, 0, read_req->num_bytes); +} + +static void dprx_execute_remote_i2c_read(struct dprx *dprx, + struct drm_dp_sideband_msg_req_body *req, + struct drm_dp_sideband_msg_reply_body *rep) +{ + struct drm_dp_remote_i2c_read *read_req = &req->u.i2c_read; + struct drm_dp_remote_i2c_read_ack_reply *read_rep = &rep->u.remote_i2c_read_ack; + struct drm_dp_remote_i2c_read_tx *tx; + struct dprx_sink *sink; + int sink_idx; + int res; + int i; + + sink_idx = dprx_port_number_to_sink_idx(dprx, read_req->port_number); + if (sink_idx == -1) { + dprx_write_nak(dprx, rep, req->req_type, DP_NAK_BAD_PARAM); + return; + } + sink = &dprx->sinks[sink_idx]; + + for (i = 0; i < read_req->num_transactions; i++) { + tx = &read_req->transactions[i]; + res = dprx_i2c_write(sink, tx->i2c_dev_id, tx->bytes, tx->num_bytes); + if (res) + goto i2c_err; + if (!tx->no_stop_bit) + dprx_i2c_stop(sink); + } + + res = dprx_i2c_read(sink, read_req->read_i2c_device_id, + read_rep->bytes, read_req->num_bytes_read); + if (res) + goto i2c_err; + dprx_i2c_stop(sink); + + rep->reply_type = DP_SIDEBAND_REPLY_ACK; + rep->req_type = DP_REMOTE_I2C_READ; + + read_rep->port_number = read_req->port_number; + read_rep->num_bytes = read_req->num_bytes_read; + return; + +i2c_err: + dprx_i2c_stop(sink); + dprx_write_nak(dprx, rep, req->req_type, DP_NAK_I2C_NAK); +} + +static void dprx_execute_remote_i2c_write(struct dprx *dprx, + struct drm_dp_sideband_msg_req_body *req, + struct drm_dp_sideband_msg_reply_body *rep) +{ + struct drm_dp_remote_i2c_write *write_req = &req->u.i2c_write; + struct drm_dp_remote_i2c_write_ack_reply *write_rep = &rep->u.remote_i2c_write_ack; + struct dprx_sink *sink; + int sink_idx; + int res; + + sink_idx = dprx_port_number_to_sink_idx(dprx, write_req->port_number); + if (sink_idx == -1) { + dprx_write_nak(dprx, rep, req->req_type, DP_NAK_BAD_PARAM); + return; + } + sink = &dprx->sinks[sink_idx]; + + res = dprx_i2c_write(sink, write_req->write_i2c_device_id, + write_req->bytes, write_req->num_bytes); + dprx_i2c_stop(sink); + if (res) { + dprx_write_nak(dprx, rep, req->req_type, DP_NAK_I2C_NAK); + return; + } + + rep->reply_type = DP_SIDEBAND_REPLY_ACK; + rep->req_type = DP_REMOTE_I2C_WRITE; + write_rep->port_number = write_req->port_number; +} + +static void dprx_execute_power_up_phy(struct dprx *dprx, + struct drm_dp_sideband_msg_req_body *req, + struct drm_dp_sideband_msg_reply_body *rep) +{ + rep->reply_type = DP_SIDEBAND_REPLY_ACK; + rep->req_type = DP_POWER_UP_PHY; + rep->u.port_number.port_number = req->u.port_num.port_number; +} + +static void dprx_execute_power_down_phy(struct dprx *dprx, + struct drm_dp_sideband_msg_req_body *req, + struct drm_dp_sideband_msg_reply_body *rep) +{ + rep->reply_type = DP_SIDEBAND_REPLY_ACK; + rep->req_type = DP_POWER_DOWN_PHY; + rep->u.port_number.port_number = req->u.port_num.port_number; +} + +static void dprx_encode_sideband_msg(struct sideband_msg *msg, u8 *buf) +{ + int idx = 0; + int i; + u8 crc4; + + buf[idx++] = ((msg->lct & 0xf) << 4) | (msg->lcr & 0xf); + for (i = 0; i < (msg->lct / 2); i++) + buf[idx++] = msg->rad[i]; + buf[idx++] = (msg->broadcast << 7) | (msg->path_msg << 6) | + ((msg->body_len + 1) & 0x3f); + buf[idx++] = (msg->somt << 7) | (msg->eomt << 6) | (msg->seqno << 4); + + crc4 = crc_dp_msg_header(buf, (idx * 2) - 1); + buf[idx - 1] |= (crc4 & 0xf); + + memcpy(&buf[idx], msg->body, msg->body_len); + idx += msg->body_len; + buf[idx] = crc_dp_msg_data(msg->body, msg->body_len); +} + +static bool dprx_decode_sideband_msg(struct sideband_msg *msg, u8 *buf, int buflen) +{ + u8 hdr_crc; + u8 hdr_len; + u8 body_crc; + int i; + u8 idx; + + if (buf[0] == 0) + return false; + hdr_len = 3; + hdr_len += ((buf[0] & 0xf0) >> 4) / 2; + if (hdr_len > buflen) + return false; + hdr_crc = crc_dp_msg_header(buf, (hdr_len * 2) - 1); + if ((hdr_crc & 0xf) != (buf[hdr_len - 1] & 0xf)) + return false; + + msg->lct = (buf[0] & 0xf0) >> 4; + msg->lcr = (buf[0] & 0xf); + idx = 1; + for (i = 0; i < (msg->lct / 2); i++) + msg->rad[i] = buf[idx++]; + msg->broadcast = (buf[idx] >> 7) & 0x1; + msg->path_msg = (buf[idx] >> 6) & 0x1; + msg->body_len = (buf[idx] & 0x3f) - 1; + idx++; + msg->somt = (buf[idx] >> 7) & 0x1; + msg->eomt = (buf[idx] >> 6) & 0x1; + msg->seqno = (buf[idx] >> 4) & 0x1; + idx++; + + if (hdr_len + msg->body_len + 1 != buflen) + return false; + + body_crc = crc_dp_msg_data(&buf[idx], msg->body_len); + if (body_crc != buf[idx + msg->body_len]) + return false; + + memcpy(msg->body, &buf[idx], msg->body_len); + idx += msg->body_len; + + return true; +} + +static bool dprx_decode_port_number_req(struct drm_dp_port_number_req *port_num, u8 *buf, int len) +{ + if (len != 1) + return false; + + port_num->port_number = buf[0] >> 4; + + return true; +} + +static bool +dprx_decode_connection_status_notify_req(struct drm_dp_connection_status_notify *conn_stat, + u8 *buf, int len) +{ + int idx = 0; + + if (len != 18) + return false; + + conn_stat->port_number = buf[idx++]; + memcpy(conn_stat->guid, &buf[idx], 16); + idx += 16; + conn_stat->legacy_device_plug_status = (buf[idx] >> 6) & 1; + conn_stat->displayport_device_plug_status = (buf[idx] >> 5) & 1; + conn_stat->message_capability_status = (buf[idx] >> 4) & 1; + conn_stat->input_port = (buf[idx] >> 3) & 1; + conn_stat->peer_device_type = buf[idx] & 0x7; + + return true; +} + +static bool dprx_decode_allocate_payload_req(struct drm_dp_allocate_payload *alloc_payload, + u8 *buf, int len) +{ + int idx = 0; + int i; + + if (len < 4) + return false; + + alloc_payload->port_number = buf[idx] >> 4; + alloc_payload->number_sdp_streams = buf[idx++] & 0xf; + alloc_payload->vcpi = buf[idx++] & 0x7f; + alloc_payload->pbn = buf[idx] << 8 | buf[idx + 1]; + idx += 2; + + if (len != idx + (alloc_payload->number_sdp_streams + 1) / 2) + return false; + + for (i = 0; i < alloc_payload->number_sdp_streams; i++) { + if ((i & 1) == 0) { + alloc_payload->sdp_stream_sink[i] = buf[idx] >> 4; + } else { + alloc_payload->sdp_stream_sink[i] = buf[idx] & 0xf; + idx++; + } + } + + return true; +} + +static bool dprx_decode_remote_dpcd_read_req(struct drm_dp_remote_dpcd_read *dpcd_read, + u8 *buf, int len) +{ + if (len != 4) + return false; + + dpcd_read->port_number = buf[0] >> 4; + dpcd_read->dpcd_address = (buf[0] & 0xf) << 16 | buf[1] << 8 | buf[2]; + dpcd_read->num_bytes = buf[3]; + + return true; +} + +static bool dprx_decode_remote_i2c_read_req(struct drm_dp_remote_i2c_read *i2c_read, + u8 *buf, int len) +{ + struct drm_dp_remote_i2c_read_tx *tx; + int idx = 0; + int i; + + if (len < 1) + return false; + + i2c_read->port_number = buf[idx] >> 4; + i2c_read->num_transactions = buf[idx] & 0x3; + idx++; + + for (i = 0; i < i2c_read->num_transactions; i++) { + tx = &i2c_read->transactions[i]; + if (len < idx + 2) + return false; + tx->i2c_dev_id = buf[idx++] & 0x7f; + tx->num_bytes = buf[idx++]; + if (len < idx + tx->num_bytes + 1) + return -1; + tx->bytes = &buf[idx]; + idx += tx->num_bytes; + tx->no_stop_bit = (buf[idx] >> 4) & 1; + tx->i2c_transaction_delay = buf[idx] & 0xf; + idx++; + } + + if (len != idx + 2) + return false; + + i2c_read->read_i2c_device_id = buf[idx++] & 0x7f; + i2c_read->num_bytes_read = buf[idx++]; + + return true; +} + +static bool dprx_decode_remote_i2c_write_req(struct drm_dp_remote_i2c_write *i2c_write, + u8 *buf, int len) +{ + int idx = 0; + + if (len < 3) + return false; + + i2c_write->port_number = buf[idx++] >> 4; + i2c_write->write_i2c_device_id = buf[idx++] & 0x7f; + i2c_write->num_bytes = buf[idx++]; + + if (len != idx + i2c_write->num_bytes) + return false; + + i2c_write->bytes = &buf[idx]; + + return true; +} + +static bool dprx_decode_sideband_req(struct drm_dp_sideband_msg_req_body *req, u8 *buf, int len) +{ + if (len == 0) + return false; + + req->req_type = buf[0] & 0x7f; + buf++; + len--; + + switch (req->req_type) { + case DP_LINK_ADDRESS: + case DP_CLEAR_PAYLOAD_ID_TABLE: + return len == 0; /* no request data */ + case DP_ENUM_PATH_RESOURCES: + case DP_POWER_UP_PHY: + case DP_POWER_DOWN_PHY: + return dprx_decode_port_number_req(&req->u.port_num, buf, len); + case DP_CONNECTION_STATUS_NOTIFY: + return dprx_decode_connection_status_notify_req(&req->u.conn_stat, buf, len); + case DP_ALLOCATE_PAYLOAD: + return dprx_decode_allocate_payload_req(&req->u.allocate_payload, buf, len); + case DP_REMOTE_DPCD_READ: + return dprx_decode_remote_dpcd_read_req(&req->u.dpcd_read, buf, len); + case DP_REMOTE_I2C_READ: + return dprx_decode_remote_i2c_read_req(&req->u.i2c_read, buf, len); + case DP_REMOTE_I2C_WRITE: + return dprx_decode_remote_i2c_write_req(&req->u.i2c_write, buf, len); + default: + return false; + } +} + +static void dprx_encode_sideband_rep(struct drm_dp_sideband_msg_reply_body *rep, u8 *buf, int *len) +{ + int idx = 0; + int i; + + buf[idx++] = (rep->reply_type & 0x1) << 7 | (rep->req_type & 0x7f); + + if (rep->reply_type) { + memcpy(&buf[idx], rep->u.nak.guid, 16); + idx += 16; + buf[idx++] = rep->u.nak.reason; + buf[idx++] = rep->u.nak.nak_data; + *len = idx; + return; + } + + switch (rep->req_type) { + case DP_LINK_ADDRESS: { + struct drm_dp_link_address_ack_reply *link_addr = &rep->u.link_addr; + struct drm_dp_link_addr_reply_port *port; + + memcpy(&buf[idx], link_addr->guid, 16); + idx += 16; + buf[idx++] = link_addr->nports; + for (i = 0; i < link_addr->nports; i++) { + port = &link_addr->ports[i]; + buf[idx++] = port->input_port << 7 | port->peer_device_type << 4 | + port->port_number; + if (port->input_port == 0) { + buf[idx++] = port->mcs << 7 | port->ddps << 6 | + port->legacy_device_plug_status << 5; + buf[idx++] = port->dpcd_revision; + memcpy(&buf[idx], port->peer_guid, 16); + idx += 16; + buf[idx++] = port->num_sdp_streams << 4 | + port->num_sdp_stream_sinks; + } else { + buf[idx++] = port->mcs << 7 | port->ddps << 6; + } + } + break; + } + case DP_ENUM_PATH_RESOURCES: { + struct drm_dp_enum_path_resources_ack_reply *path_res = &rep->u.path_resources; + + buf[idx++] = path_res->port_number << 4 | path_res->fec_capable; + buf[idx++] = path_res->full_payload_bw_number >> 8; + buf[idx++] = path_res->full_payload_bw_number & 0xff; + buf[idx++] = path_res->avail_payload_bw_number >> 8; + buf[idx++] = path_res->avail_payload_bw_number & 0xff; + break; + } + case DP_ALLOCATE_PAYLOAD: { + struct drm_dp_allocate_payload_ack_reply *alloc_payload = &rep->u.allocate_payload; + + buf[idx++] = alloc_payload->port_number << 4; + buf[idx++] = alloc_payload->vcpi & 0x3f; + buf[idx++] = alloc_payload->allocated_pbn >> 8; + buf[idx++] = alloc_payload->allocated_pbn & 0xff; + break; + } + case DP_REMOTE_DPCD_READ: { + struct drm_dp_remote_dpcd_read_ack_reply *dpcd_read = &rep->u.remote_dpcd_read_ack; + + buf[idx++] = dpcd_read->port_number & 0xf; + buf[idx++] = dpcd_read->num_bytes; + memcpy(&buf[idx], dpcd_read->bytes, dpcd_read->num_bytes); + idx += dpcd_read->num_bytes; + break; + } + case DP_REMOTE_I2C_READ: { + struct drm_dp_remote_i2c_read_ack_reply *i2c_read = &rep->u.remote_i2c_read_ack; + + buf[idx++] = i2c_read->port_number & 0xf; + buf[idx++] = i2c_read->num_bytes; + memcpy(&buf[idx], i2c_read->bytes, i2c_read->num_bytes); + idx += i2c_read->num_bytes; + break; + } + case DP_REMOTE_I2C_WRITE: + buf[idx++] = rep->u.remote_i2c_write_ack.port_number & 0xf; + break; + case DP_POWER_UP_PHY: + case DP_POWER_DOWN_PHY: + buf[idx++] = rep->u.port_number.port_number << 4; + break; + } + *len = idx; +} + +static void dprx_execute_msg_transaction(struct dprx *dprx, + struct drm_dp_sideband_msg_req_body *req, + struct drm_dp_sideband_msg_reply_body *rep) +{ + switch (req->req_type) { + case DP_LINK_ADDRESS: + dprx_execute_link_address(dprx, req, rep); + break; + case DP_CONNECTION_STATUS_NOTIFY: + dprx_execute_connection_status_notify(dprx, req, rep); + break; + case DP_ENUM_PATH_RESOURCES: + dprx_execute_enum_path_resources(dprx, req, rep); + break; + case DP_ALLOCATE_PAYLOAD: + dprx_execute_allocate_payload(dprx, req, rep); + break; + case DP_CLEAR_PAYLOAD_ID_TABLE: + dprx_execute_clear_payload_id_table(dprx, req, rep); + break; + case DP_REMOTE_DPCD_READ: + dprx_execute_remote_dpcd_read(dprx, req, rep); + break; + case DP_REMOTE_I2C_READ: + dprx_execute_remote_i2c_read(dprx, req, rep); + break; + case DP_REMOTE_I2C_WRITE: + dprx_execute_remote_i2c_write(dprx, req, rep); + break; + case DP_POWER_UP_PHY: + dprx_execute_power_up_phy(dprx, req, rep); + break; + case DP_POWER_DOWN_PHY: + dprx_execute_power_down_phy(dprx, req, rep); + break; + default: + dprx_write_nak(dprx, rep, req->req_type, DP_NAK_BAD_PARAM); + break; + } +} + +static void dprx_handle_msg_transaction(struct dprx *dprx, + struct msg_transaction_rxbuf *rxbuf, + struct msg_transaction_txbuf *txbuf) +{ + bool decoded; + struct drm_dp_sideband_msg_req_body req; + struct drm_dp_sideband_msg_reply_body rep; + + decoded = dprx_decode_sideband_req(&req, rxbuf->buf, rxbuf->len); + if (decoded) + dprx_execute_msg_transaction(dprx, &req, &rep); + else + dprx_write_nak(dprx, &rep, req.req_type, DP_NAK_BAD_PARAM); + dprx_encode_sideband_rep(&rep, txbuf->buf, &txbuf->len); + txbuf->written = 0; +} + +static void dprx_msg_transaction_append(struct msg_transaction_rxbuf *rxbuf, + struct msg_transaction_meta *meta, + struct sideband_msg *msg) +{ + int append_len; + + append_len = min(msg->body_len, sizeof(rxbuf->buf) - rxbuf->len); + memcpy(rxbuf->buf + rxbuf->len, msg->body, append_len); + rxbuf->len += append_len; + + if (msg->somt) { + meta->lct = msg->lct; + memcpy(meta->rad, msg->rad, msg->lct / 2); + meta->seqno = msg->seqno; + } +} + +static void dprx_msg_transaction_extract(struct msg_transaction_txbuf *txbuf, + struct msg_transaction_meta *meta, + struct sideband_msg *msg) +{ + int hdr_len = 3 + meta->lct / 2; + int body_len; + bool somt; + bool eomt; + + body_len = txbuf->len - txbuf->written; + /* trim body_len so that the sideband msg fits into 48 bytes */ + body_len = min(body_len, 48 - 1 - hdr_len); + + somt = (txbuf->written == 0); + eomt = (txbuf->written + body_len == txbuf->len); + + msg->lct = meta->lct; + msg->lcr = meta->lct - 1; + memcpy(msg->rad, meta->rad, meta->lct / 2); + msg->broadcast = false; + msg->path_msg = false; + msg->somt = somt; + msg->eomt = eomt; + msg->seqno = meta->seqno; + + memcpy(msg->body, txbuf->buf + txbuf->written, body_len); + msg->body_len = body_len; + + txbuf->written += body_len; +} + +static void dprx_msg_transaction_clear_rxbuf(struct msg_transaction_rxbuf *rxbuf) +{ + rxbuf->len = 0; +} + +static void dprx_msg_transaction_clear_txbuf(struct msg_transaction_txbuf *txbuf) +{ + txbuf->len = 0; + txbuf->written = 0; +} + +static bool dprx_msg_transaction_txbuf_empty(struct msg_transaction_txbuf *txbuf) +{ + return txbuf->written == txbuf->len; +} + +static void dprx_write_pending_sideband_msg(struct dprx *dprx) +{ + struct msg_transaction_txbuf *txbuf; + struct msg_transaction_meta *meta; + struct sideband_msg msg; + + if (WARN_ON_ONCE(!dprx->mt_pending)) + return; + + txbuf = &dprx->mt_txbuf[dprx->mt_seqno]; + meta = &dprx->mt_meta[dprx->mt_seqno]; + + dprx_msg_transaction_extract(txbuf, meta, &msg); + if (dprx_msg_transaction_txbuf_empty(txbuf)) { + dprx->mt_seqno = !dprx->mt_seqno; + txbuf = &dprx->mt_txbuf[dprx->mt_seqno]; + if (dprx_msg_transaction_txbuf_empty(txbuf)) + dprx->mt_pending = false; + } + + dprx_encode_sideband_msg(&msg, dprx->down_rep_buf); +} + +static void dprx_signal_irq(struct dprx *dprx, int irq) +{ + dprx->irq_vector |= irq; + dprx_pulse_hpd(dprx); +} + +static void dprx_handle_sideband_msg(struct dprx *dprx, struct sideband_msg *msg) +{ + struct msg_transaction_rxbuf *rxbuf = &dprx->mt_rxbuf[msg->seqno]; + struct msg_transaction_txbuf *txbuf = &dprx->mt_txbuf[msg->seqno]; + struct msg_transaction_meta *meta = &dprx->mt_meta[msg->seqno]; + + if (msg->somt) + dprx_msg_transaction_clear_rxbuf(rxbuf); + dprx_msg_transaction_append(rxbuf, meta, msg); + + if (msg->eomt) { + /* drop the message if txbuf isn't empty */ + if (!dprx_msg_transaction_txbuf_empty(txbuf)) + return; + dprx_handle_msg_transaction(dprx, rxbuf, txbuf); + + if (!dprx->mt_pending) { + dprx->mt_pending = true; + dprx->mt_seqno = msg->seqno; + if (!dprx->down_rep_pending) { + dprx_write_pending_sideband_msg(dprx); + dprx_signal_irq(dprx, DP_DOWN_REP_MSG_RDY); + dprx->down_rep_pending = true; + } + } + } +} + +static u8 dprx_caps[16] = { + [DP_DPCD_REV] = DP_DPCD_REV_14, + [DP_MAX_LINK_RATE] = DPRX_MAX_LINK_RATE, + [DP_MAX_LANE_COUNT] = DP_ENHANCED_FRAME_CAP | DP_TPS3_SUPPORTED | + DPRX_MAX_LANE_COUNT, + [DP_MAX_DOWNSPREAD] = DP_TPS4_SUPPORTED | DP_MAX_DOWNSPREAD_0_5, + [DP_MAIN_LINK_CHANNEL_CODING] = DP_CAP_ANSI_8B10B, + [DP_RECEIVE_PORT_0_CAP_0] = DP_LOCAL_EDID_PRESENT, +}; + +static u8 dprx_read_caps(struct dprx *dprx, u32 offset) +{ + return dprx_caps[offset]; +} + +static u8 dprx_read_mstm_cap(struct dprx *dprx) +{ + return dprx->has_mst; +} + +static u8 dprx_read_guid(struct dprx *dprx, u32 offset) +{ + return dprx->guid[offset]; +} + +static void dprx_write_guid(struct dprx *dprx, u32 offset, u8 val) +{ + dprx->guid[offset] = val; +} + +static u8 dprx_read_link_bw(struct dprx *dprx) +{ + u32 reg = dprx_read(dprx, DPRX_RX_CONTROL); + + return (reg >> DPRX_RX_CONTROL_LINK_RATE_SHIFT) & DPRX_RX_CONTROL_LINK_RATE_MASK; +} + +static void dprx_write_link_bw(struct dprx *dprx, u8 val) +{ + u32 reg; + + if (val != DP_LINK_BW_1_62 && val != DP_LINK_BW_2_7 && + val != DP_LINK_BW_5_4 && val != DP_LINK_BW_8_1) + return; + + if (val > DPRX_MAX_LINK_RATE) + return; + + reg = dprx_read(dprx, DPRX_RX_CONTROL); + reg &= ~(DPRX_RX_CONTROL_LINK_RATE_MASK << DPRX_RX_CONTROL_LINK_RATE_SHIFT); + reg |= val << DPRX_RX_CONTROL_LINK_RATE_SHIFT; + reg |= 1 << DPRX_RX_CONTROL_RECONFIG_LINKRATE; + dprx_write(dprx, DPRX_RX_CONTROL, reg); +} + +static u8 dprx_read_lane_count(struct dprx *dprx) +{ + u32 reg = dprx_read(dprx, DPRX_RX_CONTROL); + + return (reg >> DPRX_RX_CONTROL_LANE_COUNT_SHIFT) & DPRX_RX_CONTROL_LANE_COUNT_MASK; +} + +static void dprx_write_lane_count(struct dprx *dprx, u8 val) +{ + u32 reg; + u8 lane_count; + + lane_count = val & DP_LANE_COUNT_MASK; + + if (lane_count != 1 && lane_count != 2 && lane_count != 4) + return; + + reg = dprx_read(dprx, DPRX_RX_CONTROL); + reg &= ~(DPRX_RX_CONTROL_LANE_COUNT_MASK << DPRX_RX_CONTROL_LANE_COUNT_SHIFT); + reg |= lane_count << DPRX_RX_CONTROL_LANE_COUNT_SHIFT; + dprx_write(dprx, DPRX_RX_CONTROL, reg); +} + +static u8 dprx_read_training_pattern(struct dprx *dprx) +{ + u32 reg; + u32 pattern; + u32 scrambler_disable; + u8 result = 0; + + reg = dprx_read(dprx, DPRX_RX_CONTROL); + pattern = (reg >> DPRX_RX_CONTROL_TP_SHIFT) & DPRX_RX_CONTROL_TP_MASK; + scrambler_disable = (reg >> DPRX_RX_CONTROL_SCRAMBLER_DISABLE) & 1; + + if (scrambler_disable) + result |= DP_LINK_SCRAMBLING_DISABLE; + result |= pattern; + + return result; +} + +static void dprx_write_training_pattern(struct dprx *dprx, u8 val) +{ + u8 pattern; + u8 scrambler_disable; + u32 reg; + + pattern = val & DP_TRAINING_PATTERN_MASK_1_4; + scrambler_disable = !!(val & DP_LINK_SCRAMBLING_DISABLE); + + reg = dprx_read(dprx, DPRX_RX_CONTROL); + reg &= ~(DPRX_RX_CONTROL_TP_MASK << DPRX_RX_CONTROL_TP_SHIFT); + reg |= pattern << DPRX_RX_CONTROL_TP_SHIFT; + reg &= ~(1 << DPRX_RX_CONTROL_SCRAMBLER_DISABLE); + reg |= scrambler_disable << DPRX_RX_CONTROL_SCRAMBLER_DISABLE; + dprx_write(dprx, DPRX_RX_CONTROL, reg); +} + +static u8 dprx_read_training_lane(struct dprx *dprx, u32 offset) +{ + struct dprx_training_control *ctl = &dprx->training_control[offset]; + u8 result = 0; + + result |= ctl->volt_swing << DP_TRAIN_VOLTAGE_SWING_SHIFT; + if (ctl->max_swing) + result |= DP_TRAIN_MAX_SWING_REACHED; + result |= ctl->pre_emph << DP_TRAIN_PRE_EMPHASIS_SHIFT; + if (ctl->max_pre_emph) + result |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED; + + return result; +} + +static void dprx_write_training_lane(struct dprx *dprx, u32 offset, u8 val) +{ + struct dprx_training_control *ctl = &dprx->training_control[offset]; + + ctl->volt_swing = (val & DP_TRAIN_VOLTAGE_SWING_MASK) >> DP_TRAIN_VOLTAGE_SWING_SHIFT; + ctl->max_swing = (val & DP_TRAIN_MAX_SWING_REACHED); + ctl->pre_emph = (val & DP_TRAIN_PRE_EMPHASIS_MASK) >> DP_TRAIN_PRE_EMPHASIS_SHIFT; + ctl->max_pre_emph = (val & DP_TRAIN_MAX_PRE_EMPHASIS_REACHED); +} + +static u8 dprx_read_mstm_ctrl(struct dprx *dprx) +{ + return (dprx_read(dprx, DPRX_MST_CONTROL1) >> DPRX_MST_CONTROL1_MST_EN) & 1; +} + +static void dprx_write_mstm_ctrl(struct dprx *dprx, u8 val) +{ + u8 mst_en = !!(val & DP_MST_EN); + u32 reg; + + reg = dprx_read(dprx, DPRX_MST_CONTROL1); + reg &= ~(1 << DPRX_MST_CONTROL1_MST_EN); + reg |= mst_en << DPRX_MST_CONTROL1_MST_EN; + dprx_write(dprx, DPRX_MST_CONTROL1, reg); +} + +static void dprx_handle_payload_allocate(struct dprx *dprx) +{ + u8 id = dprx->payload_allocate_set; + u8 start = dprx->payload_allocate_start_time_slot; + u8 count = dprx->payload_allocate_time_slot_count; + + if (id == 0 && start == 0 && count == 0x3f) { + dprx_clear_vc_payload_table(dprx); + } else { + if (count == 0) + dprx_deallocate_vc_payload(dprx, start, id); + else + dprx_allocate_vc_payload(dprx, start, count, id); + dprx_set_vc_payload_table(dprx); + } + dprx->payload_table_updated = 1; +} + +static u8 dprx_read_payload_allocate_set(struct dprx *dprx) +{ + return dprx->payload_allocate_set; +} + +static void dprx_write_payload_allocate_set(struct dprx *dprx, u8 val) +{ + dprx->payload_allocate_set = val & DP_PAYLOAD_ALLOCATE_SET_MASK; +} + +static u8 dprx_read_payload_allocate_start_time_slot(struct dprx *dprx) +{ + return dprx->payload_allocate_start_time_slot; +} + +static void dprx_write_payload_allocate_start_time_slot(struct dprx *dprx, u8 val) +{ + dprx->payload_allocate_start_time_slot = val & DP_PAYLOAD_ALLOCATE_START_TIME_SLOT_MASK; +} + +static u8 dprx_read_payload_allocate_time_slot_count(struct dprx *dprx) +{ + return dprx->payload_allocate_time_slot_count; +} + +static void dprx_write_payload_allocate_time_slot_count(struct dprx *dprx, u8 val) +{ + dprx->payload_allocate_time_slot_count = val & DP_PAYLOAD_ALLOCATE_TIME_SLOT_COUNT_MASK; + dprx_handle_payload_allocate(dprx); +} + +static u8 dprx_read_sink_count(struct dprx *dprx) +{ + return dprx->sink_count; +} + +static u8 dprx_read_device_service_irq_vector(struct dprx *dprx) +{ + return dprx->irq_vector; +} + +static void dprx_write_device_service_irq_vector(struct dprx *dprx, u8 val) +{ + dprx->irq_vector &= ~val; + + if (val & DP_DOWN_REP_MSG_RDY) { + if (dprx->mt_pending) { + dprx_write_pending_sideband_msg(dprx); + dprx_signal_irq(dprx, DP_DOWN_REP_MSG_RDY); + } else { + dprx->down_rep_pending = false; + } + } +} + +static u8 dprx_read_lane0_1_status(struct dprx *dprx) +{ + u32 reg; + u8 res = 0; + + reg = dprx_read(dprx, DPRX_RX_STATUS); + if ((reg >> DPRX_RX_STATUS_CR_LOCK(0)) & 1) + res |= DP_LANE_CR_DONE; + if ((reg >> DPRX_RX_STATUS_CR_LOCK(1)) & 1) + res |= DP_LANE_CR_DONE << 4; + if ((reg >> DPRX_RX_STATUS_SYM_LOCK(0)) & 1) + res |= DP_LANE_CHANNEL_EQ_DONE | DP_LANE_SYMBOL_LOCKED; + if ((reg >> DPRX_RX_STATUS_SYM_LOCK(1)) & 1) + res |= (DP_LANE_CHANNEL_EQ_DONE | DP_LANE_SYMBOL_LOCKED) << 4; + + return res; +} + +static u8 dprx_read_lane2_3_status(struct dprx *dprx) +{ + u32 reg; + u8 res = 0; + + reg = dprx_read(dprx, DPRX_RX_STATUS); + if ((reg >> DPRX_RX_STATUS_CR_LOCK(2)) & 1) + res |= DP_LANE_CR_DONE; + if ((reg >> DPRX_RX_STATUS_CR_LOCK(3)) & 1) + res |= DP_LANE_CR_DONE << 4; + if ((reg >> DPRX_RX_STATUS_SYM_LOCK(2)) & 1) + res |= DP_LANE_CHANNEL_EQ_DONE | DP_LANE_SYMBOL_LOCKED; + if ((reg >> DPRX_RX_STATUS_SYM_LOCK(3)) & 1) + res |= (DP_LANE_CHANNEL_EQ_DONE | DP_LANE_SYMBOL_LOCKED) << 4; + + return res; +} + +static u8 dprx_read_lane_align_status(struct dprx *dprx) +{ + return (dprx_read(dprx, DPRX_RX_STATUS) >> DPRX_RX_STATUS_INTERLANE_ALIGN) & 1; +} + +static u8 dprx_read_sink_status(struct dprx *dprx) +{ + return (dprx_read(dprx, DPRX_VBID(0)) >> DPRX_VBID_MSA_LOCK) & 1; +} + +static u8 dprx_read_adjust_request(struct dprx *dprx, + struct dprx_training_control *ctl0, + struct dprx_training_control *ctl1) +{ + u8 next_volt_swing0; + u8 next_pre_emph0; + u8 next_volt_swing1; + u8 next_pre_emph1; + + if (dprx_adjust_needed(dprx)) { + dprx_training_control_next(ctl0, &next_volt_swing0, &next_pre_emph0); + dprx_training_control_next(ctl1, &next_volt_swing1, &next_pre_emph1); + } else { + next_volt_swing0 = ctl0->volt_swing; + next_pre_emph0 = ctl0->pre_emph; + next_volt_swing1 = ctl1->volt_swing; + next_pre_emph1 = ctl1->pre_emph; + } + + return next_volt_swing0 << DP_ADJUST_VOLTAGE_SWING_LANE0_SHIFT | + next_pre_emph0 << DP_ADJUST_PRE_EMPHASIS_LANE0_SHIFT | + next_volt_swing1 << DP_ADJUST_VOLTAGE_SWING_LANE1_SHIFT | + next_pre_emph1 << DP_ADJUST_PRE_EMPHASIS_LANE1_SHIFT; +} + +static u8 dprx_read_adjust_request_lane0_1(struct dprx *dprx) +{ + return dprx_read_adjust_request(dprx, + &dprx->training_control[0], + &dprx->training_control[1]); +} + +static u8 dprx_read_adjust_request_lane2_3(struct dprx *dprx) +{ + return dprx_read_adjust_request(dprx, + &dprx->training_control[2], + &dprx->training_control[3]); +} + +static u8 dprx_read_payload_table_update_status(struct dprx *dprx) +{ + u32 reg; + u32 act_handled; + u8 result = 0; + + reg = dprx_read(dprx, DPRX_MST_STATUS1); + act_handled = (reg >> DPRX_MST_STATUS1_VCPTAB_ACT_ACK) & 1; + + if (dprx->payload_table_updated) + result |= DP_PAYLOAD_TABLE_UPDATED; + if (act_handled) + result |= DP_PAYLOAD_ACT_HANDLED; + + return result; +} + +static void dprx_write_payload_table_update_status(struct dprx *dprx, u8 val) +{ + u32 reg; + + if (val & DP_PAYLOAD_TABLE_UPDATED) { + dprx->payload_table_updated = 0; + reg = dprx_read(dprx, DPRX_MST_CONTROL1); + reg &= ~(1 << DPRX_MST_CONTROL1_VCPTAB_UPD_REQ); + dprx_write(dprx, DPRX_MST_CONTROL1, reg); + } +} + +static u8 dprx_read_vc_payload_id_slot(struct dprx *dprx, u32 offset) +{ + return dprx->payload_table[offset + 1]; +} + +static u8 dprx_read_down_req(struct dprx *dprx, u32 offset) +{ + return dprx->down_req_buf[offset]; +} + +static void dprx_write_down_req(struct dprx *dprx, u32 offset, u8 val) +{ + struct sideband_msg msg; + + dprx->down_req_buf[offset] = val; + if (dprx_decode_sideband_msg(&msg, dprx->down_req_buf, offset + 1)) + dprx_handle_sideband_msg(dprx, &msg); +} + +static u8 dprx_read_down_rep(struct dprx *dprx, u32 offset) +{ + return dprx->down_rep_buf[offset]; +} + +struct dprx_dpcd_handler { + u32 addr; + u32 range_len; + union { + u8 (*point)(struct dprx *dprx); + u8 (*range)(struct dprx *dprx, u32 offset); + } read; + union { + void (*point)(struct dprx *dprx, u8 val); + void (*range)(struct dprx *dprx, u32 offset, u8 val); + } write; +}; + +static void dprx_write_noop(struct dprx *dprx, u8 val) +{ +} + +static void dprx_write_noop_range(struct dprx *dprx, u32 offset, u8 val) +{ +} + +static struct dprx_dpcd_handler dprx_dpcd_handlers[] = { + { 0x00000, 16, { .range = dprx_read_caps }, + { .range = dprx_write_noop_range } }, + { 0x00021, 0, { .point = dprx_read_mstm_cap }, + { .point = dprx_write_noop } }, + { 0x00030, 16, { .range = dprx_read_guid }, + { .range = dprx_write_guid } }, + { 0x00100, 0, { .point = dprx_read_link_bw }, + { .point = dprx_write_link_bw } }, + { 0x00101, 0, { .point = dprx_read_lane_count }, + { .point = dprx_write_lane_count } }, + { 0x00102, 0, { .point = dprx_read_training_pattern }, + { .point = dprx_write_training_pattern } }, + { 0x00103, 4, { .range = dprx_read_training_lane }, + { .range = dprx_write_training_lane } }, + { 0x00111, 0, { .point = dprx_read_mstm_ctrl }, + { .point = dprx_write_mstm_ctrl } }, + { 0x001c0, 0, { .point = dprx_read_payload_allocate_set }, + { .point = dprx_write_payload_allocate_set } }, + { 0x001c1, 0, { .point = dprx_read_payload_allocate_start_time_slot }, + { .point = dprx_write_payload_allocate_start_time_slot } }, + { 0x001c2, 0, { .point = dprx_read_payload_allocate_time_slot_count }, + { .point = dprx_write_payload_allocate_time_slot_count } }, + { 0x00200, 0, { .point = dprx_read_sink_count }, + { .point = dprx_write_noop } }, + { 0x00201, 0, { .point = dprx_read_device_service_irq_vector }, + { .point = dprx_write_device_service_irq_vector } }, + { 0x00202, 0, { .point = dprx_read_lane0_1_status }, + { .point = dprx_write_noop } }, + { 0x00203, 0, { .point = dprx_read_lane2_3_status }, + { .point = dprx_write_noop } }, + { 0x00204, 0, { .point = dprx_read_lane_align_status }, + { .point = dprx_write_noop } }, + { 0x00205, 0, { .point = dprx_read_sink_status }, + { .point = dprx_write_noop } }, + { 0x00206, 0, { .point = dprx_read_adjust_request_lane0_1 }, + { .point = dprx_write_noop } }, + { 0x00207, 0, { .point = dprx_read_adjust_request_lane2_3 }, + { .point = dprx_write_noop } }, + { 0x002c0, 0, { .point = dprx_read_payload_table_update_status }, + { .point = dprx_write_payload_table_update_status } }, + { 0x002c1, 63, { .range = dprx_read_vc_payload_id_slot }, + { .range = dprx_write_noop_range } }, + { 0x01000, 48, { .range = dprx_read_down_req }, + { .range = dprx_write_down_req } }, + { 0x01400, 48, { .range = dprx_read_down_rep }, + { .range = dprx_write_noop_range } }, + /* Event Status Indicator is a copy of 200h - 205h */ + { 0x02002, 0, { .point = dprx_read_sink_count }, + { .point = dprx_write_noop } }, + { 0x02003, 0, { .point = dprx_read_device_service_irq_vector }, + { .point = dprx_write_device_service_irq_vector } }, + { 0x0200c, 0, { .point = dprx_read_lane0_1_status }, + { .point = dprx_write_noop } }, + { 0x0200d, 0, { .point = dprx_read_lane2_3_status }, + { .point = dprx_write_noop } }, + { 0x0200e, 0, { .point = dprx_read_lane_align_status }, + { .point = dprx_write_noop } }, + { 0x0200f, 0, { .point = dprx_read_sink_status }, + { .point = dprx_write_noop } }, + /* Extended Receiver Capability is a copy of 0h - 0fh */ + { 0x02200, 16, { .range = dprx_read_caps }, + { .range = dprx_write_noop_range } }, +}; + +static bool dprx_dpcd_handler_match(struct dprx_dpcd_handler *handler, u32 addr) +{ + if (handler->range_len == 0) + return addr == handler->addr; + else + return addr >= handler->addr && addr < handler->addr + handler->range_len; +} + +static void dprx_dpcd_handler_run(struct dprx_dpcd_handler *handler, + struct dprx *dprx, u32 addr, u8 *val, bool read) +{ + if (read) { + if (handler->range_len == 0) + *val = handler->read.point(dprx); + else + *val = handler->read.range(dprx, addr - handler->addr); + } else { + if (handler->range_len == 0) + handler->write.point(dprx, *val); + else + handler->write.range(dprx, addr - handler->addr, *val); + } +} + +static void dprx_dpcd_access(struct dprx *dprx, u32 addr, u8 *val, bool read) +{ + struct dprx_dpcd_handler *handler; + int i; + + for (i = 0; i < ARRAY_SIZE(dprx_dpcd_handlers); i++) { + handler = &dprx_dpcd_handlers[i]; + if (dprx_dpcd_handler_match(handler, addr)) { + dprx_dpcd_handler_run(handler, dprx, addr, val, read); + return; + } + } + + /* for unsupported registers, writes are ignored and reads return 0. */ + if (read) + *val = 0; +} + +static void dprx_handle_native_aux(struct dprx *dprx, struct aux_msg *req, struct aux_msg *rep) +{ + bool read = req->cmd & 1; + u8 *data; + int i; + + rep->cmd = DP_AUX_NATIVE_REPLY_ACK; + if (read) { + rep->len = req->len; + data = rep->data; + } else { + rep->len = 0; + data = req->data; + } + + for (i = 0; i < req->len; i++) + dprx_dpcd_access(dprx, req->addr + i, data + i, read); +} + +static void dprx_handle_i2c_read(struct dprx *dprx, struct aux_msg *req, struct aux_msg *rep) +{ + int res; + + res = dprx_i2c_read(&dprx->sinks[0], req->addr, rep->data, req->len); + if (!res) { + rep->cmd = DP_AUX_I2C_REPLY_ACK; + rep->len = req->len; + } else { + rep->cmd = DP_AUX_I2C_REPLY_NACK; + rep->len = 0; + } +} + +static void dprx_handle_i2c_write(struct dprx *dprx, struct aux_msg *req, struct aux_msg *rep) +{ + int res; + + res = dprx_i2c_write(&dprx->sinks[0], req->addr, req->data, req->len); + if (!res) + rep->cmd = DP_AUX_I2C_REPLY_ACK; + else + rep->cmd = DP_AUX_I2C_REPLY_NACK; + rep->len = 0; +} + +static void dprx_decode_aux_request(struct aux_msg *req, struct aux_buf *buf) +{ + req->cmd = buf->data[0] >> 4; + req->addr = (buf->data[0] & 0xf) << 16 | buf->data[1] << 8 | buf->data[2]; + if (buf->len < 4) { + req->len = 0; + } else { + req->len = buf->data[3] + 1; + memcpy(req->data, &buf->data[4], req->len); + } +} + +static void dprx_encode_aux_reply(struct aux_msg *rep, struct aux_buf *buf) +{ + buf->data[0] = rep->cmd << 4; + memcpy(&buf->data[1], rep->data, rep->len); + buf->len = rep->len + 1; +} + +static void dprx_handle_aux(struct dprx *dprx, struct aux_buf *req_buf, struct aux_buf *rep_buf) +{ + struct aux_msg req; + struct aux_msg rep; + + dprx_decode_aux_request(&req, req_buf); + + if (req.cmd & 8) { + dprx_handle_native_aux(dprx, &req, &rep); + } else { + if (req.cmd & 1) + dprx_handle_i2c_read(dprx, &req, &rep); + else + dprx_handle_i2c_write(dprx, &req, &rep); + if (!(req.cmd & DP_AUX_I2C_MOT)) + dprx_i2c_stop(&dprx->sinks[0]); + } + + dprx_encode_aux_reply(&rep, rep_buf); +} + +static int dprx_read_aux(struct dprx *dprx, struct aux_buf *buf) +{ + u32 control = dprx_read(dprx, DPRX_AUX_CONTROL); + int i; + + /* check MSG_READY */ + if (!((dprx_read(dprx, DPRX_AUX_STATUS) >> DPRX_AUX_STATUS_MSG_READY) & 1)) + return -1; + + /* read LENGTH */ + buf->len = (control >> DPRX_AUX_CONTROL_LENGTH_SHIFT) & DPRX_AUX_CONTROL_LENGTH_MASK; + if (buf->len > 20) + buf->len = 20; + + /* read request */ + for (i = 0; i < buf->len; i++) + buf->data[i] = dprx_read(dprx, DPRX_AUX_COMMAND + i); + + return 0; +} + +static void dprx_write_aux(struct dprx *dprx, struct aux_buf *buf) +{ + u32 reg; + int i; + + if (!((dprx_read(dprx, DPRX_AUX_STATUS) >> DPRX_AUX_STATUS_READY_TO_TX) & 1)) + return; + + if (buf->len > 17) + buf->len = 17; + for (i = 0; i < buf->len; i++) + dprx_write(dprx, DPRX_AUX_COMMAND + i, buf->data[i]); + + reg = dprx_read(dprx, DPRX_AUX_CONTROL); + reg &= ~(DPRX_AUX_CONTROL_LENGTH_MASK << DPRX_AUX_CONTROL_LENGTH_SHIFT); + reg |= buf->len << DPRX_AUX_CONTROL_LENGTH_SHIFT; + reg |= 1 << DPRX_AUX_CONTROL_TX_STROBE; + dprx_write(dprx, DPRX_AUX_CONTROL, reg); +} + +static irqreturn_t dprx_isr(int irq, void *data) +{ + struct dprx *dprx = data; + struct aux_buf request; + struct aux_buf reply; + unsigned int reg; + + reg = readl(dprx->iobase_irq + DPRX_IRQ_CLR); + if (!reg) + return IRQ_NONE; + + if (!dprx_read_aux(dprx, &request)) { + spin_lock(&dprx->lock); + dprx_handle_aux(dprx, &request, &reply); + spin_unlock(&dprx->lock); + dprx_write_aux(dprx, &reply); + } + + writel(reg, dprx->iobase_irq + DPRX_IRQ_CLR); + + return IRQ_HANDLED; +} + +static void dprx_reset_hw(struct dprx *dprx) +{ + int i; + + /* set link rate to 1.62 Gbps and lane count to 1 */ + dprx_write(dprx, DPRX_RX_CONTROL, + DP_LINK_BW_1_62 << DPRX_RX_CONTROL_LINK_RATE_SHIFT | + 1 << DPRX_RX_CONTROL_RECONFIG_LINKRATE | + DPRX_RX_CONTROL_CHANNEL_CODING_8B10B << DPRX_RX_CONTROL_CHANNEL_CODING_SHIFT | + 1 << DPRX_RX_CONTROL_LANE_COUNT_SHIFT); + /* clear VC payload ID table */ + for (i = 0; i < 8; i++) + dprx_write(dprx, DPRX_MST_VCPTAB(i), 0); + dprx_write(dprx, DPRX_MST_CONTROL1, 1 << DPRX_MST_CONTROL1_VCPTAB_UPD_FORCE); +} + +static void dprx_reset(struct dprx *dprx) +{ + int i; + + memset(dprx->guid, 0, sizeof(dprx->guid)); + memset(dprx->training_control, 0, sizeof(dprx->training_control)); + + dprx->payload_allocate_set = 0; + dprx->payload_allocate_start_time_slot = 0; + dprx->payload_allocate_time_slot_count = 0; + memset(dprx->payload_table, 0, sizeof(dprx->payload_table)); + dprx->payload_table_updated = 0; + + memset(dprx->payload_id, 0, sizeof(dprx->payload_id)); + memset(dprx->payload_pbn, 0, sizeof(dprx->payload_pbn)); + dprx->payload_pbn_total = 0; + + dprx->irq_vector = 0; + + memset(dprx->down_req_buf, 0, sizeof(dprx->down_req_buf)); + memset(dprx->down_rep_buf, 0, sizeof(dprx->down_rep_buf)); + + for (i = 0; i < 2; i++) { + dprx_msg_transaction_clear_rxbuf(&dprx->mt_rxbuf[i]); + dprx_msg_transaction_clear_txbuf(&dprx->mt_txbuf[i]); + } + dprx->mt_seqno = 0; + dprx->mt_pending = false; + dprx->down_rep_pending = false; + + dprx_reset_hw(dprx); +} + +#define to_dprx(sd) container_of(sd, struct dprx, subdev) + +static int dprx_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) +{ + struct dprx *dprx = to_dprx(sd); + struct dprx_sink *sink; + u32 end_block = edid->start_block + edid->blocks; + unsigned long flags; + int res = 0; + + memset(edid->reserved, 0, sizeof(edid->reserved)); + + if (edid->pad >= dprx->sink_count) + return -EINVAL; + + spin_lock_irqsave(&dprx->lock, flags); + + sink = &dprx->sinks[edid->pad]; + if (edid->start_block == 0 && edid->blocks == 0) { + edid->blocks = sink->blocks; + goto out; + } + if (sink->blocks == 0) { + res = -ENODATA; + goto out; + } + if (edid->start_block >= sink->blocks) { + res = -EINVAL; + goto out; + } + if (end_block > sink->blocks) { + end_block = sink->blocks; + edid->blocks = end_block - edid->start_block; + } + + memcpy(edid->edid, sink->edid + edid->start_block * 128, edid->blocks * 128); + +out: + spin_unlock_irqrestore(&dprx->lock, flags); + + return res; +} + +static int dprx_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) +{ + struct dprx *dprx = to_dprx(sd); + struct dprx_sink *sink; + bool prev_hpd; + bool cur_hpd; + unsigned long flags; + + memset(edid->reserved, 0, sizeof(edid->reserved)); + + if (edid->pad >= dprx->sink_count) + return -EINVAL; + if (edid->start_block != 0) + return -EINVAL; + if (edid->blocks > DPRX_MAX_EDID_BLOCKS) { + edid->blocks = DPRX_MAX_EDID_BLOCKS; + return -E2BIG; + } + + spin_lock_irqsave(&dprx->lock, flags); + sink = &dprx->sinks[edid->pad]; + /* + * This is an MST DisplayPort device, which means that one HPD + * line controls all the video streams. The way this is handled + * in s_edid is that the HPD line is controlled by the presence + * of only the first stream's EDID. This allows, for example, to + * first set the second streams's EDID and then the first one in + * order to reduce the amount of AUX communication. + */ + prev_hpd = dprx->sinks[0].blocks > 0; + sink->blocks = edid->blocks; + memcpy(sink->edid, edid->edid, edid->blocks * 128); + cur_hpd = dprx->sinks[0].blocks > 0; + if (!prev_hpd && cur_hpd) + dprx_reset(dprx); + spin_unlock_irqrestore(&dprx->lock, flags); + + if (!prev_hpd && cur_hpd) { + dprx_set_hpd(dprx, 1); + } else if (prev_hpd && !cur_hpd) { + dprx_set_hpd(dprx, 0); + } else if (prev_hpd && cur_hpd) { + /* HPD replug - pulse for >2ms */ + dprx_set_hpd(dprx, 0); + usleep_range(2000, 4000); + dprx_set_hpd(dprx, 1); + } + + return 0; +} + +static int dprx_query_dv_timings(struct v4l2_subdev *sd, unsigned int pad, + struct v4l2_dv_timings *timings) +{ + struct dprx *dprx = to_dprx(sd); + u32 htotal, vtotal; + u32 hsp, hsw; + u32 hstart, vstart; + u32 vsp, vsw; + u32 hwidth, vheight; + + if (pad >= dprx->sink_count) + return -EINVAL; + + if (!((dprx_read(dprx, DPRX_VBID(pad)) >> DPRX_VBID_MSA_LOCK) & 1)) + return -ENOLINK; + + htotal = dprx_read(dprx, DPRX_MSA_HTOTAL(pad)); + vtotal = dprx_read(dprx, DPRX_MSA_VTOTAL(pad)); + hsp = dprx_read(dprx, DPRX_MSA_HSP(pad)); + hsw = dprx_read(dprx, DPRX_MSA_HSW(pad)); + hstart = dprx_read(dprx, DPRX_MSA_HSTART(pad)); + vstart = dprx_read(dprx, DPRX_MSA_VSTART(pad)); + vsp = dprx_read(dprx, DPRX_MSA_VSP(pad)); + vsw = dprx_read(dprx, DPRX_MSA_VSW(pad)); + hwidth = dprx_read(dprx, DPRX_MSA_HWIDTH(pad)); + vheight = dprx_read(dprx, DPRX_MSA_VHEIGHT(pad)); + + memset(timings, 0, sizeof(*timings)); + timings->type = V4L2_DV_BT_656_1120; + timings->bt.width = hwidth; + timings->bt.height = vheight; + timings->bt.polarities = (!vsp) | (!hsp) << 1; + timings->bt.hfrontporch = htotal - hstart - hwidth; + timings->bt.hsync = hsw; + timings->bt.hbackporch = hstart - hsw; + timings->bt.vfrontporch = vtotal - vstart - vheight; + timings->bt.vsync = vsw; + timings->bt.vbackporch = vstart - vsw; + + return 0; +} + +/* DisplayPort 1.4 capabilities */ + +static const struct v4l2_dv_timings_cap dprx_timings_cap = { + .type = V4L2_DV_BT_656_1120, + .bt = { + .min_width = 0, + .max_width = 7680, + .min_height = 0, + .max_height = 4320, + .min_pixelclock = 0, + .max_pixelclock = 1350000000, /* 8.1Gbps * 4lanes / 24bpp */ + .standards = V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT | + V4L2_DV_BT_STD_CVT | V4L2_DV_BT_STD_GTF, + .capabilities = V4L2_DV_BT_CAP_PROGRESSIVE | + V4L2_DV_BT_CAP_REDUCED_BLANKING | + V4L2_DV_BT_CAP_CUSTOM, + }, +}; + +static int dprx_enum_dv_timings(struct v4l2_subdev *sd, struct v4l2_enum_dv_timings *timings) +{ + return v4l2_enum_dv_timings_cap(timings, &dprx_timings_cap, + NULL, NULL); +} + +static int dprx_dv_timings_cap(struct v4l2_subdev *sd, struct v4l2_dv_timings_cap *cap) +{ + *cap = dprx_timings_cap; + + return 0; +} + +static const struct v4l2_subdev_pad_ops dprx_pad_ops = { + .get_edid = dprx_get_edid, + .set_edid = dprx_set_edid, + .dv_timings_cap = dprx_dv_timings_cap, + .enum_dv_timings = dprx_enum_dv_timings, + .query_dv_timings = dprx_query_dv_timings, +}; + +static const struct v4l2_subdev_ops dprx_subdev_ops = { + .pad = &dprx_pad_ops, +}; + +static const struct media_entity_operations dprx_entity_ops = { + .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = v4l2_subdev_get_fwnode_pad_1_to_1, +}; + +static int dprx_init_pads(struct dprx *dprx) +{ + int i; + + for (i = 0; i < dprx->sink_count; i++) + dprx->pads[i].flags = MEDIA_PAD_FL_SOURCE; + + return media_entity_pads_init(&dprx->subdev.entity, dprx->sink_count, dprx->pads); +} + +static int dprx_probe(struct platform_device *pdev) +{ + struct dprx *dprx; + int irq; + int res; + + dprx = devm_kzalloc(&pdev->dev, sizeof(*dprx), GFP_KERNEL); + if (!dprx) + return -ENOMEM; + dprx->dev = &pdev->dev; + platform_set_drvdata(pdev, dprx); + + dprx->iobase = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(dprx->iobase)) + return PTR_ERR(dprx->iobase); + + dprx->iobase_irq = devm_platform_ioremap_resource(pdev, 1); + if (IS_ERR(dprx->iobase_irq)) + return PTR_ERR(dprx->iobase_irq); + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + + res = devm_request_irq(dprx->dev, irq, dprx_isr, 0, "intel-dprx", dprx); + if (res) + return res; + + dprx->has_mst = device_property_read_bool(&pdev->dev, "intel,has-mst"); + dprx->sink_count = dprx->has_mst ? 4 : 1; + + dprx->subdev.owner = THIS_MODULE; + dprx->subdev.dev = &pdev->dev; + v4l2_subdev_init(&dprx->subdev, &dprx_subdev_ops); + v4l2_set_subdevdata(&dprx->subdev, &pdev->dev); + snprintf(dprx->subdev.name, sizeof(dprx->subdev.name), "%s %s", + KBUILD_MODNAME, dev_name(&pdev->dev)); + dprx->subdev.flags = V4L2_SUBDEV_FL_HAS_DEVNODE; + + dprx->subdev.entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER; + dprx->subdev.entity.ops = &dprx_entity_ops; + + res = dprx_init_pads(dprx); + if (res) + return res; + + res = v4l2_async_register_subdev(&dprx->subdev); + if (res) + return res; + + dprx_set_hpd(dprx, 0); + dprx_reset_hw(dprx); + + dprx_set_irq(dprx, 1); + writel(DPRX_IRQ_AUX, dprx->iobase_irq + DPRX_IRQ_MASK); + + return 0; +} + +static void dprx_remove(struct platform_device *pdev) +{ + struct dprx *dprx = platform_get_drvdata(pdev); + + /* disable interrupts */ + writel(0, dprx->iobase_irq + DPRX_IRQ_MASK); + dprx_set_irq(dprx, 0); + + v4l2_async_unregister_subdev(&dprx->subdev); +} + +static const struct of_device_id dprx_match_table[] = { + { .compatible = "intel,dprx" }, + { }, +}; + +static struct platform_driver dprx_platform_driver = { + .probe = dprx_probe, + .remove_new = dprx_remove, + .driver = { + .name = "intel-dprx", + .of_match_table = dprx_match_table, + }, +}; + +module_platform_driver(dprx_platform_driver); + +MODULE_AUTHOR("Paweł Anikiel "); +MODULE_DESCRIPTION("Intel DisplayPort RX IP core driver"); +MODULE_LICENSE("GPL"); From patchwork Mon Feb 12 13:13:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Anikiel?= X-Patchwork-Id: 199768 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2423691dyd; Mon, 12 Feb 2024 05:24:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsOReuG6wwDxGgbyskmWGPweL0Lg9IYdznHcU64dk5Pls5Pu3pPMlKLBL/+3E7LZvHqBOS X-Received: by 2002:a05:622a:243:b0:42c:a452:9b61 with SMTP id c3-20020a05622a024300b0042ca4529b61mr1434279qtx.1.1707744262305; Mon, 12 Feb 2024 05:24:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707744262; cv=pass; d=google.com; s=arc-20160816; b=fh+f2MsRKfjvO9ImaWcsoAyfedxNzxcGc0W2MiNJ6RLg6b2n+gygfh70io5yba39Ll Z9j4uzlC7fWVEIfTyFhGCkCZo6x7Ma+HJqQ8ZWYZk3HtBFakQOmsHhpvdpSfv3IiCbhQ 8eCwUiz9P9E86iYPf8XzW5MkPUm79oCLuG8GquviY4d16yW9v4YdrDABsdP91FcvRHt6 98ATGPGKT1ALRAkcuq6o057oQFOznTQYk6tDntGfgcFHJxGXKt+EKbeQH8hV+e05lw8m wmYyc5Yvo/U3LNvqcnR823XkaKNsjHGIJDKYkHwA1hgVp67HsVyIud2G/3sIBziTJ9wF qcwg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=rRe13GXsBNZ8mkxLlyJ1MfL527/NzLwP4cfZxeK7UxI=; fh=wBaLBUvrBiS/KmkYaivyZsuCbRAPaRVwqneAc5PAg4M=; b=kY6HadXx/gtMQmKazXmiaDmOaDC0sHFNIpD01B/1XjmEn2/a2aNoWDtY6Z1mLUlmra gJYpNNJUqpBjWKPIkic9SPapf1MEJfTzAEcJEMsxSQ9vobmpzp0ZHODs4Nd0byERbsuQ rgGfvlrlxptzAWuflBfFVpaw8XZ3cqXNGq/FHIvfnpvSFd1fOclcj28M+gjuA9NYbKkx 1v16JIRAsJfJ6c+spQ1G9iSqyNzwqRRh13QkvNoRX7D32X7hGiR75ohFbeMEfS0UT4li A74CeFUkWhZorSi05ffzoYbm0jA66UAalBdt58fUD/ELbzuXlCXhCL4nIaK4/BARBkqI oEtA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=VvujglPx; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61645-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61645-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCW+HpvUgwjdv4aTvAVH3wPAtLtjh0jYaKmzyuiiysOn3u882b97D3AO/pK1pND/KKudDAetrpsHl6EHps/+FsdYVakAeA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ku17-20020a05622a0a9100b0042c4dc130cbsi339603qtb.768.2024.02.12.05.24.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:24:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61645-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=VvujglPx; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61645-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61645-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1C1EF1C21B82 for ; Mon, 12 Feb 2024 13:24:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B58544DA01; Mon, 12 Feb 2024 13:14:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VvujglPx" Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 295334C626 for ; Mon, 12 Feb 2024 13:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743677; cv=none; b=nNAf77iag4FGRQByPGPeW1cvVQNCZZu4tslsOgfeZeLWeET5xUcVZ8c5EM9Cv0lKeQHwLSre+HRn+REH9ZzAB3u07jC5gD3E6YS+nWgf2oqWBkA19HxhVnbtTok5/RP/zbGIHk690kb9tQ9vnGlSuT7t6M1fPAudcjr+JgZMgBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743677; c=relaxed/simple; bh=MGljuiY0b08CbfXabKHR3arSgSpNqpPXAmOerQ85JFw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=DfmUjO1y4vaB3z8bArNb/N4/O28ByBHIhIanw+Z5h5k2du3da20IMYvJUMW4QUbLaiEft0vFojNU2gvd2wLPyq1RNdah281jC/F+Zdx2lSEBreSWao9aeq2XmJU+CIcaBvxeNEigHYbZip4jXO26IFxkjCYdJf6HQwn2iankPAg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VvujglPx; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-410d0660929so4553595e9.0 for ; Mon, 12 Feb 2024 05:14:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707743673; x=1708348473; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=rRe13GXsBNZ8mkxLlyJ1MfL527/NzLwP4cfZxeK7UxI=; b=VvujglPxX48kcJgSADWgCn1UVFBsld3Ij/wDfqpgYVn1zsXY7SmwUjSAXwBSXV6HLb sM2IGHWBSjEZnICV1NG4pJK7rWTKtGuiGMaRcq6MfC0O+gjilZZyClxo0KtLMpM6j9Cg qEcQ6hWQO2s7xB85rujQcKjApX1kT7AhRVdDxnrTTtf3RhcExrZZqZXPmFYw7Nw66UYH fBAv9sePGF2NYVitZGth4lA618JHCqS8Be/dus8MoINpvDWxpN+1jEQUz6FleyB0nu5K lo3N39KUVh+xLXS5yC2P7uYt4UszfaJAFNYtDQHtB1bUw5n/9qjmZe49Tv7k3xTSZ24F /cGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707743673; x=1708348473; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=rRe13GXsBNZ8mkxLlyJ1MfL527/NzLwP4cfZxeK7UxI=; b=SP3a0doTwJ/Nl1SWdEADkoiz46dk4XWL8Vo+AYcF8pozi0NecnUBkyVuIMoXSGWEKb LW/VGH4QG/KurcIS+HmB4m2kBfUOsTJqp2InSAHSQD6+ZP7BFbOYaNX0CBXlz6RyF4XF ylRlDX56NfVqzSSADau37k0RsJ1NODxDE9P1qBJXtyViLc8J6pddqovFQ3mBB8oGrvRV W0+MFvwbEn/5BU9A+YbYrBXnDMHHXUxkOxTtJHKZ0RpvBFPm2wCZ/cMdQGeoCBInHnjf smRNTEtEHc3nbRn2ZDB5b73QM/jAqUgyfKXZuLm1zQ4k61jYlyRxpifDkz4NxsatxzGv vjYQ== X-Gm-Message-State: AOJu0Yzxfq/JH784iPmSH8eHyfzx+vILkmqwg4M/yikW7npLWddadkW0 /pcvrsMEpOSTcg/Sm1VNuxGIPe2UJPWBH3pK3f6uiNeSISKG1FCiajwSWQZ+w3VgKO1uhYcXnar c4kFtYPLXGA== X-Received: from szatan.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:2d83]) (user=panikiel job=sendgmr) by 2002:a05:600c:4c96:b0:410:bb99:7ea2 with SMTP id g22-20020a05600c4c9600b00410bb997ea2mr35246wmp.3.1707743673486; Mon, 12 Feb 2024 05:14:33 -0800 (PST) Date: Mon, 12 Feb 2024 13:13:21 +0000 In-Reply-To: <20240212131323.2162161-1-panikiel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240212131323.2162161-1-panikiel@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240212131323.2162161-8-panikiel@google.com> Subject: [PATCH 7/9] media: dt-bindings: Add Chameleon v3 framebuffer From: " =?utf-8?q?Pawe=C5=82_Anikiel?= " To: airlied@gmail.com, akpm@linux-foundation.org, conor+dt@kernel.org, daniel@ffwll.ch, dinguyen@kernel.org, hverkuil-cisco@xs4all.nl, krzysztof.kozlowski+dt@linaro.org, maarten.lankhorst@linux.intel.com, mchehab@kernel.org, mripard@kernel.org, robh+dt@kernel.org, tzimmermann@suse.de Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, chromeos-krk-upstreaming@google.com, ribalda@chromium.org, " =?utf-8?q?Pawe?= =?utf-8?q?=C5=82_Anikiel?= " X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790699647638509895 X-GMAIL-MSGID: 1790699647638509895 The Chameleon v3 uses the framebuffer IP core to take the video signal from different sources and directly write frames into memory. Signed-off-by: Paweł Anikiel --- .../bindings/media/google,chv3-fb.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/google,chv3-fb.yaml diff --git a/Documentation/devicetree/bindings/media/google,chv3-fb.yaml b/Documentation/devicetree/bindings/media/google,chv3-fb.yaml new file mode 100644 index 000000000000..ba6643cc7232 --- /dev/null +++ b/Documentation/devicetree/bindings/media/google,chv3-fb.yaml @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/google,chv3-fb.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Google Chameleon v3 video framebuffer + +maintainers: + - Paweł Anikiel + +properties: + compatible: + const: google,chv3-fb + + reg: + items: + - description: core registers + - description: irq registers + + interrupts: + maxItems: 1 + + google,legacy-format: + type: boolean + description: The incoming video stream is in 32-bit padded mode. + + google,no-endpoint: + type: boolean + description: + The framebuffer isn't connected to a controllable endpoint. + The video interface still works, but EDID control is unavailable + and DV timing information only reports the active video width/height. + + port: + $ref: /schemas/graph.yaml#/properties/port + +required: + - compatible + - reg + - interrupts + +allOf: + - if: + not: + required: + - google,no-endpoint + then: + required: + - port + +additionalProperties: false + +examples: + - | + video@c0060500 { + compatible = "google,chv3-fb"; + reg = <0xc0060500 0x100>, + <0xc0060f20 0x10>; + interrupts = ; + google,legacy-format; + google,no-endpoint; + }; + + - | + video@c0060600 { + compatible = "google,chv3-fb"; + reg = <0xc0060600 0x100>, + <0xc0060f30 0x10>; + interrupts = ; + + port { + fb_mst0_0: endpoint { + remote-endpoint = <&dprx_mst_0>; + }; + }; + }; From patchwork Mon Feb 12 13:13:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Anikiel?= X-Patchwork-Id: 199770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2424159dyd; Mon, 12 Feb 2024 05:24:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFj2DJQWSAtrb6/nWLvGV3Ocb6UVWe8aVM6ywiATtlzG4urtz3VrG84xelOj9GKS+XauJeq X-Received: by 2002:a17:90a:17c5:b0:296:a767:f6d2 with SMTP id q63-20020a17090a17c500b00296a767f6d2mr4353501pja.38.1707744299321; Mon, 12 Feb 2024 05:24:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707744299; cv=pass; d=google.com; s=arc-20160816; b=siYY5nHNrZj6fsW4oVzMM7gXrHsSebOP+UjBCImoQoTvUr1GmUR8oPCPNSjTUDdPi/ +osXeieVycC+y60SHgQx3ewoQf0cbo7r4NV+l+pxzcAgrTN8MrTeog26bf751Z4ye4hh ophj1HlcDPkVvkZEuipteKvp4BZYMdKK9cwuzfbt7xiEwmK3Dt0+9W93WB7+Y4kXgv9H jeMGXgtCphJ1iSZkGSqva7ffenSX4qRBz+wpa49Hy5iYbGplau1Ldm+rLmUBSgx1yq6a AwuSZ7dxxBKfXXdhwoNs2Wjg1GuCFtpdcuhT9iImcCj9mKR/6KQAGVh6LxVF7LFhWJOa ARXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=weAbudB3k3wPqp+4oDt/WoN+euSYJ/f5cRIeaqwfqjk=; fh=b3O5OcrtdBSbdgIpcCAePWtnFEiRpZ6y+A/KvIsHRbA=; b=Ufk9zEZigfE6ai7M1QQrpYF98Qpw2uGf48Jd6DQFiIrdsfUSonQFHJKmN5SfkrAhRS TT54R57ZYTNS9raHfksFbQyPRumIruWgch0bZwOV2/AOzwjGE/BSKitDQ18OErYTR9PE NK1nyisyiZuEJ9uFjd0rcnhYjTDCcH/P6Ab3HPOxZpy4w+nGRhESqWL8I8FGo8Ot9gTy 8OOi6hoXQYQYZYy/IxFHradCwnhgOxM0YIz6E84wi6VhjHwP1/IZxv5X++41F9pchWVZ SuSYzNy5dFElySqK6WWGVpYpkvX3H739B28/WLzpSGTnI0tS9d4IiGUPmqjzyajL7omW GJQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vrROLVyI; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61647-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61647-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCU5h7mzlFyZllBQ5PC5MZJxEdTXM4Gpti8O8sRy34NdhV1rE+Nyiv8tpKYIhe6cre0JntiCIrV0FZjnAm2eaZ0vEn3Ppw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id qe15-20020a17090b4f8f00b00296167b289asi281087pjb.135.2024.02.12.05.24.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:24:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61647-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vrROLVyI; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61647-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61647-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1766E28AF91 for ; Mon, 12 Feb 2024 13:24:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C22B24EB22; Mon, 12 Feb 2024 13:14:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vrROLVyI" Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08E313B787 for ; Mon, 12 Feb 2024 13:14:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743678; cv=none; b=nIu/AWskZKsH71RpeZEkyCJWntnaiK6jeNk8GIUPmIYFnIiPTxpz95C6oCOo/3RdxUrxWrU6d8Q+mVx8XAW9Adcwl2Q1dNhru8WRINuv9A9txqQ6Ybh61KUYVvIFGQyyXuF9AD0oamR4Hpzw3PvXmD3PlJEq21gbKL6x5kmGdrA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743678; c=relaxed/simple; bh=IrOdF2IkBl2jU+cs6JkBmakSjiXX4Bcd9lmtDOI7FSE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jZyJv8tHnf7akCkDsIdDPKSMmbDMd6wZ2RGQ//60rXR7jmKvrGO3k9EY0RJ112SiLsnVz1iZA7bWC3PWkpEZiUA8hwdTjIXrVcq6erFtJv3S8Cdl+Nkofa3nRWiU9RemXnDZ1ermmBBai3iYsQ00prgPcF7Tvi0LXA8SdrNdxPA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vrROLVyI; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-33b6e444c76so1038828f8f.3 for ; Mon, 12 Feb 2024 05:14:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707743675; x=1708348475; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=weAbudB3k3wPqp+4oDt/WoN+euSYJ/f5cRIeaqwfqjk=; b=vrROLVyIUc69oKVb/Bvw5eOwovBUGYXKKzKUT/25HPfN0B6IteVu+BQ++koOzHbXfx TBwJpYFJrqeWTuTNQy+rcgBRzxYPBt/klLvADjNcRcVN8rB0vU543aYI//jr2K3D3W1Q 8GKCpCVJkDpwVaWjFFX019frbnJZbX3VhSCg8SIjBvR9EU74Hsy1svR7MZn20paPnaby SkUR+tDYJswUdeMQyIW/YkXd+V20xCCpNy5Ciq02xKEa6GwSJQgOjr2POGVrr+EpBZyU +9eVm1+6fl75VqgMYTJ3Q00YRjE6qeCZxLqT941GAYEvyyfXRzZeO8SbuCskZLpXZvMp ESnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707743675; x=1708348475; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=weAbudB3k3wPqp+4oDt/WoN+euSYJ/f5cRIeaqwfqjk=; b=NwWIRbP6WkGPY0R4PDYh0cufWqpEWPwkH74b43U+14BK2reDzyXroLke9ulmI9sUw5 uKU+RYjr7nstomjgH0HlTpaGclvL04+2MoMmDySDkOFHcjnO4+hJBWKbrtk6QIMt8aZM UluHqM7Zdsqk/3GrzQKj8n+E0O93Ne8X6b9J9Mk7UP0may2xyiVnHunkl8rdi1fLCxCO 1VcfQtgsg/YXCLOIJNbP7blqHQEGxXxbIxgsfby9UAZVLweTL4ylyDvKJmLaBHHxtwPs DK///GmIyTSpgXiVu2DhKywpBE2UEgzFa1/P4Ftv8ExV9xan46BCpPY2Dl64ly3vgh91 gERQ== X-Gm-Message-State: AOJu0YzNOlCUdHY5gqhvO5t1mWfiZbBacLxB89xdVHEfOcNFS4+Zkp+5 E3DLs9OZ9zxVIJHx4jN7EZXclA6DoGwka7oF3Gwc+UnHxiCG8K1JhJhIrTzczVpECDmXaaQ0Tcu vysfQeD/nRQ== X-Received: from szatan.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:2d83]) (user=panikiel job=sendgmr) by 2002:a05:6000:a16:b0:33b:6489:a97d with SMTP id co22-20020a0560000a1600b0033b6489a97dmr13629wrb.14.1707743675651; Mon, 12 Feb 2024 05:14:35 -0800 (PST) Date: Mon, 12 Feb 2024 13:13:22 +0000 In-Reply-To: <20240212131323.2162161-1-panikiel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240212131323.2162161-1-panikiel@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240212131323.2162161-9-panikiel@google.com> Subject: [PATCH 8/9] media: dt-bindings: Add Intel Displayport RX IP From: " =?utf-8?q?Pawe=C5=82_Anikiel?= " To: airlied@gmail.com, akpm@linux-foundation.org, conor+dt@kernel.org, daniel@ffwll.ch, dinguyen@kernel.org, hverkuil-cisco@xs4all.nl, krzysztof.kozlowski+dt@linaro.org, maarten.lankhorst@linux.intel.com, mchehab@kernel.org, mripard@kernel.org, robh+dt@kernel.org, tzimmermann@suse.de Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, chromeos-krk-upstreaming@google.com, ribalda@chromium.org, " =?utf-8?q?Pawe?= =?utf-8?q?=C5=82_Anikiel?= " X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790699686529933317 X-GMAIL-MSGID: 1790699686529933317 The Intel Displayport RX IP is a part of the DisplayPort Intel FPGA IP Core. It implements a DisplayPort 1.4 receiver capable of HBR3 video capture and Multi-Stream Transport. The user guide can be found here: https://www.intel.com/programmable/technical-pdfs/683273.pdf Signed-off-by: Paweł Anikiel --- .../devicetree/bindings/media/intel,dprx.yaml | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/intel,dprx.yaml diff --git a/Documentation/devicetree/bindings/media/intel,dprx.yaml b/Documentation/devicetree/bindings/media/intel,dprx.yaml new file mode 100644 index 000000000000..3ed37e0a4a94 --- /dev/null +++ b/Documentation/devicetree/bindings/media/intel,dprx.yaml @@ -0,0 +1,125 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/intel,dprx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Intel DisplayPort RX IP + +maintainers: + - Paweł Anikiel + +properties: + compatible: + const: intel,dprx + + reg: + items: + - description: core registers + - description: irq registers + + interrupts: + maxItems: 1 + + intel,has-mst: + type: boolean + description: The device supports Multi-Stream Transport + + port: + $ref: /schemas/graph.yaml#/properties/port + description: SST main link + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: MST virtual channel 0 or SST main link + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: MST virtual channel 1 + + port@2: + $ref: /schemas/graph.yaml#/properties/port + description: MST virtual channel 2 + + port@3: + $ref: /schemas/graph.yaml#/properties/port + description: MST virtual channel 3 + +required: + - compatible + - reg + - interrupts + +allOf: + - if: + required: + - intel,has-mst + then: + required: + - ports + else: + required: + - port + +additionalProperties: false + +examples: + - | + dprx@c0062000 { + compatible = "intel,dprx"; + reg = <0xc0062000 0x800>, + <0xc0060f80 0x10>; + interrupts = ; + intel,has-mst; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dprx_mst_0: endpoint { + remote-endpoint = <&fb_mst0_0>; + }; + }; + + port@1 { + reg = <1>; + dprx_mst_1: endpoint { + remote-endpoint = <&fb_mst1_0>; + }; + }; + + port@2 { + reg = <2>; + dprx_mst_2: endpoint { + remote-endpoint = <&fb_mst2_0>; + }; + }; + + port@3 { + reg = <3>; + dprx_mst_3: endpoint { + remote-endpoint = <&fb_mst3_0>; + }; + }; + }; + }; + + - | + dprx@c0064000 { + compatible = "intel,dprx"; + reg = <0xc0064000 0x800>, + <0xc0060fe0 0x10>; + interrupts = ; + + port { + dprx_sst_0: endpoint { + remote-endpoint = <&fb_sst_0>; + }; + }; + }; From patchwork Mon Feb 12 13:13:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Anikiel?= X-Patchwork-Id: 199800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2435205dyd; Mon, 12 Feb 2024 05:45:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUEd3NC55tAkhVS8FY/HT/SKkSRva1XuJTCLfZ2wN+owvf3t2gQ5a75k6dqe1bxgP2qlxzHhCK4aCH1FyJYc/mbnAo96w== X-Google-Smtp-Source: AGHT+IGSg2SCMLMM8ek51iKDIh3CNFUH7gF7xMRhqLOmUwmFAQPNK2ObL4N5eXA3E0RJrb+hO4n4 X-Received: by 2002:a05:6358:760e:b0:17a:c976:c143 with SMTP id r14-20020a056358760e00b0017ac976c143mr8846176rwg.12.1707745544671; Mon, 12 Feb 2024 05:45:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707745544; cv=pass; d=google.com; s=arc-20160816; b=P3u0/qxang+R21nFAKHJs6d16JQmmfT7uoSBOhXWUVh2WcoYpO+1sjc2Oq6JmqJ9Lu iC+PAd2Bx04gnCpznonalJZiFH+NXDBtttynWH57YvoLC5ZfJTO9eEohCZvl/D+fsSLA 4wXq82WvEfsIS8SoHT0pwLao6V9vbaTi9oalSi5ZHffHiLRFcKZkEQQtBGYfD0x+6AZc 5DPQsvfSmU7KUuQ3pMtWHGKL3UhzlVD8iMOHiTmUkFhXM7qcV+3qhKtYIVMqCWLe5G1r iINbM7uqnBlpoIUsbHMjrgrxBtIFHBH9COwI1dJmFeqMZY4M0jxIOeRjI6MsjI+V7kQY 9t7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=oX2+cr2GJmybLTxSkR2z2RsI+0zR7H0TC6zqB4mg2qY=; fh=625fdOsI9EtI+SKddmVMkhT3tDvre2W8w7Qk4TbYj74=; b=1BxFG1IaceAk0qm4wvsLOOwgg+IUoCd+O/+FjhOKifrQO3FNC2ovW/5e7CDG3dgAKS CgQVxBHV1sYNjhH1I+KycqPMrwNLiPEd2EHfV+GMLWuArX5lxY796ZoRRBARFcjZT399 +V9TjzgdaCXtCQd/+L1QU977FhomsZEFPB6gInMyH+hKQIG/3ttN0sBhpNzRy3mbJCX3 U6SnBXsHiwxoPbPTSDKYBTNIs2ssm45j9u41EtlY7BA+dnHZFXIqDQlSRkzardaXKvT0 3M3zM33FjSZt+iyBUiU5v6eV1CtWKTW5ofTZd5Jgp0gBrHUBwqNnNKgCfKJMqL5iY+j1 FV1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=jRqmHLtg; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61650-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61650-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCVyXOILX2CBitGRi4rr7k3GkpOHC0Pdr6791mt3mYm1rV2Lz8y0HNbsKppeLeLN7GhvlelybGvz+emjusSZHjOnPgQxFg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id m20-20020a638c14000000b005d8e1dc1df8si269836pgd.705.2024.02.12.05.45.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:45:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61650-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=jRqmHLtg; arc=pass (i=1 spf=pass spfdomain=flex--panikiel.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61650-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61650-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 3CF37B21930 for ; Mon, 12 Feb 2024 13:25:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D0A54F613; Mon, 12 Feb 2024 13:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jRqmHLtg" Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A38B04D5B5 for ; Mon, 12 Feb 2024 13:14:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743682; cv=none; b=Ybj5KpJab+92QXCywpZmQwc2Io63Z4AOfEsm68wwzclPtgIg5sW0HTNbueeYw9GcZ8wYZ0WH9O3//bn7bn/1cO/KsJSde9BMp6xhM6hB7ruN0XX8zFoahaatin2Icu1VSu79RD/JrjivDYOEi1F34G/JEt0NmY0imDHoX+x8GGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743682; c=relaxed/simple; bh=gcqzXqPvCid0bdGkdQCOqBvfMk4/JJEe5ZxnNjAwSB8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hpbZjnYWMBojf4j3wptazLNT7eQ55iA/h32A5R+u2Zb4G361rHmgwxHdENxCK80tV3uejiIOZVtWlQMNQ8Cwor4WmGg1kmGJjq6aeCXzUzZb0zpKzdnYOXftuNxaT7TyR1YFVh9JuI5vzWRz+UuOxSDzTXFsJyAS0jTW4B61WT4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jRqmHLtg; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--panikiel.bounces.google.com Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-337bf78ef28so1119834f8f.3 for ; Mon, 12 Feb 2024 05:14:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707743678; x=1708348478; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=oX2+cr2GJmybLTxSkR2z2RsI+0zR7H0TC6zqB4mg2qY=; b=jRqmHLtg7k4CXJvCxsRaBZ0K5UWhwRRGzTE7xsjyWHSWN3Xr/T2M9uxJ3/SGl2zrS5 QkVlOeaKv7TrrkDA+O1PJ17mEOX85b2ZZAcLnKkJqLVhfBXeFYmD0DvXUr77rs76oK8l WQNDu/67fg3/36L2ZlFGOxvoAaa+4npg2sZm1Zynkaisr/H/WouGMdMiSllVBfuyB8Hf qeF4bAMzi53gOEvEDYngOrgQ7Te55ZyrNgWfhbwSoqRTs965FLqMkBFFuPtH5xrKIPi7 avkBKr0a+Yu9J7pRcrJl7j0L097/rw2hnhmON1PdHdBkz4BJrOFlSsmJkAGannDM2dWi QLfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707743678; x=1708348478; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=oX2+cr2GJmybLTxSkR2z2RsI+0zR7H0TC6zqB4mg2qY=; b=Ts0RtbEbzSFF1gf0s2LjTPqUDe3+W8NZ/Di4mXnB1FdvvT9LOw/OWpEgugrGUaEpom hpHv/8zClNiv77uavRnb8yBUJlmal7aTckpugQe5ZqMAlAQPvGqkCKpGY83q8LMj5e7H tVDs2u3h9HByu3cOPjV99j5pYZKm4jDGmUzqkNxs7HSQzl5onC1J8QfajhB7TEdwOLYW q/vP5p1++3Oeqp67vpi0I3nw4mSRwONUHK2oBqZNPl7GcBfWSH/u6rjTHj8NPR0B0PIo pxH84OKZz45BizVAh9gv1rpHGGTF4WNuQYsgBFAsP/MdjtwiPiCkW/5fNE2gtJHi9qv1 mtTg== X-Forwarded-Encrypted: i=1; AJvYcCWSP8Acag2tQZtPJwkPwzLziJCvKNHp/d9lSpJ/SeBNGqcGP5yzXDz6NLk/V6T4FddQNJE9Elhcx2ELvUhzsIo819kj+32yCupSrmJG X-Gm-Message-State: AOJu0YwANUBkFAaI9DxRSMTmyirkJC6/YXC3LKoWLvj5KITQgkSSzUOY 569x/A8f8HOEkgd+S2gZ/NUtmzggq+vyr0PgUh5BweavhgFPhwD2neAkCtBrA3xtt/pP4KelEcB hjybTnAePFg== X-Received: from szatan.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:2d83]) (user=panikiel job=sendgmr) by 2002:a05:6000:1751:b0:33b:8f6:2a77 with SMTP id m17-20020a056000175100b0033b08f62a77mr15650wrf.2.1707743677947; Mon, 12 Feb 2024 05:14:37 -0800 (PST) Date: Mon, 12 Feb 2024 13:13:23 +0000 In-Reply-To: <20240212131323.2162161-1-panikiel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240212131323.2162161-1-panikiel@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240212131323.2162161-10-panikiel@google.com> Subject: [PATCH 9/9] ARM: dts: chameleonv3: Add video device nodes From: " =?utf-8?q?Pawe=C5=82_Anikiel?= " To: airlied@gmail.com, akpm@linux-foundation.org, conor+dt@kernel.org, daniel@ffwll.ch, dinguyen@kernel.org, hverkuil-cisco@xs4all.nl, krzysztof.kozlowski+dt@linaro.org, maarten.lankhorst@linux.intel.com, mchehab@kernel.org, mripard@kernel.org, robh+dt@kernel.org, tzimmermann@suse.de Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, chromeos-krk-upstreaming@google.com, ribalda@chromium.org, " =?utf-8?q?Pawe?= =?utf-8?q?=C5=82_Anikiel?= " X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790700991898781039 X-GMAIL-MSGID: 1790700991898781039 Add device nodes for the video system present on the Chameleon v3. It consists of six framebuffers and two Intel Displayport receivers. Signed-off-by: Paweł Anikiel --- .../socfpga/socfpga_arria10_chameleonv3.dts | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/arch/arm/boot/dts/intel/socfpga/socfpga_arria10_chameleonv3.dts b/arch/arm/boot/dts/intel/socfpga/socfpga_arria10_chameleonv3.dts index 422d00cd4c74..9bc0c1672b18 100644 --- a/arch/arm/boot/dts/intel/socfpga/socfpga_arria10_chameleonv3.dts +++ b/arch/arm/boot/dts/intel/socfpga/socfpga_arria10_chameleonv3.dts @@ -10,6 +10,136 @@ / { compatible = "google,chameleon-v3", "enclustra,mercury-aa1", "altr,socfpga-arria10", "altr,socfpga"; + soc { + fb0: video@c0060500 { + compatible = "google,chv3-fb"; + reg = <0xc0060500 0x100>, + <0xc0060f20 0x10>; + interrupts = ; + google,legacy-format; + google,no-endpoint; + }; + + fb_mst0: video@c0060600 { + compatible = "google,chv3-fb"; + reg = <0xc0060600 0x100>, + <0xc0060f30 0x10>; + interrupts = ; + + port { + fb_mst0_0: endpoint { + remote-endpoint = <&dprx_mst_0>; + }; + }; + }; + + fb_mst1: video@c0060700 { + compatible = "google,chv3-fb"; + reg = <0xc0060700 0x100>, + <0xc0060f40 0x10>; + interrupts = ; + + port { + fb_mst1_0: endpoint { + remote-endpoint = <&dprx_mst_1>; + }; + }; + }; + + fb_mst2: video@c0060800 { + compatible = "google,chv3-fb"; + reg = <0xc0060800 0x100>, + <0xc0060f50 0x10>; + interrupts = ; + + port { + fb_mst2_0: endpoint { + remote-endpoint = <&dprx_mst_2>; + }; + }; + }; + + fb_mst3: video@c0060900 { + compatible = "google,chv3-fb"; + reg = <0xc0060900 0x100>, + <0xc0060f60 0x10>; + interrupts = ; + + port { + fb_mst3_0: endpoint { + remote-endpoint = <&dprx_mst_3>; + }; + }; + }; + + fb_sst: video@c0060a00 { + compatible = "google,chv3-fb"; + reg = <0xc0060a00 0x100>, + <0xc0060f70 0x10>; + interrupts = ; + + port { + fb_sst_0: endpoint { + remote-endpoint = <&dprx_sst_0>; + }; + }; + }; + + dprx_mst: dprx@c0062000 { + compatible = "intel,dprx"; + reg = <0xc0062000 0x800>, + <0xc0060f80 0x10>; + interrupts = ; + intel,has-mst; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dprx_mst_0: endpoint { + remote-endpoint = <&fb_mst0_0>; + }; + }; + + port@1 { + reg = <1>; + dprx_mst_1: endpoint { + remote-endpoint = <&fb_mst1_0>; + }; + }; + + port@2 { + reg = <2>; + dprx_mst_2: endpoint { + remote-endpoint = <&fb_mst2_0>; + }; + }; + + port@3 { + reg = <3>; + dprx_mst_3: endpoint { + remote-endpoint = <&fb_mst3_0>; + }; + }; + }; + }; + + dprx_sst: dprx@c0064000 { + compatible = "intel,dprx"; + reg = <0xc0064000 0x800>, + <0xc0060fe0 0x10>; + interrupts = ; + + port { + dprx_sst_0: endpoint { + remote-endpoint = <&fb_sst_0>; + }; + }; + }; + }; + aliases { serial0 = &uart0; i2c0 = &i2c0;