From patchwork Mon Aug 14 04:29:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reka Norman X-Patchwork-Id: 13352351 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 F0F661FAA for ; Mon, 14 Aug 2023 04:36:05 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2681223aaacso2565586a91.0 for ; Sun, 13 Aug 2023 21:36:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1691987765; x=1692592565; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J3Yp2zAtjbeDJ1QhLpOKL+IzkWDr56KaxN6gm4H+hUQ=; b=j4hCLshmCxUrUqzEgfl3+kiO58h9WICLyh88yqSwF9BVsk6NFCvfvCcAPJt4v/RMM3 5UGM32X4uDDDVO59AUIpA2SnIEUpWBXd8owYRt9P1kVsBceOJ9hND7X1LgSm9vSBk4or czT5GnFzQ9mZWZDGjrRhk4eDeg8wiKHqAJecQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691987765; x=1692592565; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J3Yp2zAtjbeDJ1QhLpOKL+IzkWDr56KaxN6gm4H+hUQ=; b=jpInG5VnDLFuwQ9yqmA99MakqskPiF3eHlBakTAod/BC0KFgQwPjTweHUQ4bon/B+9 /HLSngehoAbW7Jq5nmhFM0UVFXgWqa2siQuyhdeZl+43WwIN2HNOxWlDGQsoHhb2nJ+r O0CeTUzwSf7pq0rCsy7GGYVSYmm7Qg7MvJX13Ez1QBReZbYBp/FyWEQlmmq0FoiUdzUj jIBpjq99jvCBeQZiLLZkwbl8ESgqjC27Vxd9ND/OQFzw9cJKOv8aeSc9hT+DyaGlwQWM hIYt9KX/TlCASvnDG5IefEyDsn1gNCDUURAtLz04AHdewyw8fw7YlzYziJYrT2tXe7jL czVQ== X-Gm-Message-State: AOJu0YwBTzJypTngcZolv8XwBPcHI+qjiFViYftBwUhG3jQCxEZv3mW3 H+EGMJ7rqjn7bSw6avkjAHbHWg== X-Google-Smtp-Source: AGHT+IEyHxoQk4dD6G3k26knq3YOynLzMONf++TpVJFDGtUHE/YNEAdF0oDACqKCPHO+wyR64CA8Vw== X-Received: by 2002:a17:90a:5a85:b0:268:808:8e82 with SMTP id n5-20020a17090a5a8500b0026808088e82mr10740711pji.1.1691987765440; Sun, 13 Aug 2023 21:36:05 -0700 (PDT) Received: from rekanorman3.syd.corp.google.com ([2401:fa00:9:14:4ae6:d1a4:27c2:80ff]) by smtp.gmail.com with ESMTPSA id ju17-20020a170903429100b001bdb0483e65sm6761865plb.265.2023.08.13.21.36.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Aug 2023 21:36:05 -0700 (PDT) From: Reka Norman To: Hans Verkuil Cc: Neil Armstrong , Daisuke Nojiri , Stefan Adolfsson , Reka Norman , Benson Leung , Guenter Roeck , Mauro Carvalho Chehab , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 5/9] media: cros-ec-cec: Support multiple ports in MKBP cec_events Date: Mon, 14 Aug 2023 14:29:14 +1000 Message-ID: <20230814043140.1108917-6-rekanorman@chromium.org> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog In-Reply-To: <20230814043140.1108917-1-rekanorman@chromium.org> References: <20230814043140.1108917-1-rekanorman@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the top four bits of the cec_events MKBP event to store the port number. Signed-off-by: Reka Norman --- drivers/media/cec/platform/cros-ec/cros-ec-cec.c | 13 +++++++++++-- include/linux/platform_data/cros_ec_commands.h | 10 ++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/media/cec/platform/cros-ec/cros-ec-cec.c b/drivers/media/cec/platform/cros-ec/cros-ec-cec.c index d674a432dfdd..eb4b778f83e9 100644 --- a/drivers/media/cec/platform/cros-ec/cros-ec-cec.c +++ b/drivers/media/cec/platform/cros-ec/cros-ec-cec.c @@ -77,8 +77,17 @@ static void handle_cec_message(struct cros_ec_cec *cros_ec_cec) static void handle_cec_event(struct cros_ec_cec *cros_ec_cec) { struct cros_ec_device *cros_ec = cros_ec_cec->cros_ec; - uint32_t events = cros_ec->event_data.data.cec_events; - struct cros_ec_cec_port *port = cros_ec_cec->ports[CEC_PORT]; + uint32_t cec_events = cros_ec->event_data.data.cec_events; + int port_num = EC_MKBP_EVENT_CEC_GET_PORT(cec_events); + uint32_t events = EC_MKBP_EVENT_CEC_GET_EVENTS(cec_events); + struct cros_ec_cec_port *port; + + if (port_num < 0 || port_num >= cros_ec_cec->num_ports) { + dev_err(cros_ec->dev, + "received CEC event for invalid port %d\n", port_num); + return; + } + port = cros_ec_cec->ports[port_num]; if (events & EC_MKBP_CEC_SEND_OK) cec_transmit_attempt_done(port->adap, CEC_TX_STATUS_OK); diff --git a/include/linux/platform_data/cros_ec_commands.h b/include/linux/platform_data/cros_ec_commands.h index 9a0c6e28f370..b7e8573a8a49 100644 --- a/include/linux/platform_data/cros_ec_commands.h +++ b/include/linux/platform_data/cros_ec_commands.h @@ -4440,6 +4440,16 @@ struct ec_response_i2c_passthru_protect { #define MAX_CEC_MSG_LEN 16 +/* + * Helper macros for packing/unpacking cec_events. + * bits[27:0] : bitmask of events from enum mkbp_cec_event + * bits[31:28]: port number + */ +#define EC_MKBP_EVENT_CEC_PACK(events, port) \ + (((events) & GENMASK(27, 0)) | (((port) & 0xf) << 28)) +#define EC_MKBP_EVENT_CEC_GET_EVENTS(event) ((event) & GENMASK(27, 0)) +#define EC_MKBP_EVENT_CEC_GET_PORT(event) (((event) >> 28) & 0xf) + /* CEC message from the AP to be written on the CEC bus */ #define EC_CMD_CEC_WRITE_MSG 0x00B8