Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Documentation/devicetree/bindings/display/apple,dcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,17 @@ properties:
$ref: /schemas/types.yaml#/definitions/uint32
description: Display coprocessor index on multi-DCP systems.

apple,hdcp-channels:
$ref: /schemas/types.yaml#/definitions/uint32-array
minItems: 1
maxItems: 2
items:
maximum: 14
description:
The Secure Enclave's HDCP interface channels assigned to this display
coprocessor. The first is the HDCP 2.2 transmitter channel of its
external output. Absent when the coprocessor has no HDCP transmitter.

apple,sleep-host-stop:
type: boolean
description:
Expand Down
2 changes: 2 additions & 0 deletions arch/arm64/boot/dts/apple/t604x-extdisp.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
mboxes = <&dcpext0_mbox>;
mbox-names = "mbox";
iommus = <&dcpext0_dart 23>;
apple,hdcp-channels = <7 8>;
/* guessed: the internal DCP uses 0x20000, J700 DISPEXT0 is +0x8000 */
apple,bw-scratch = <&pmgr_dcp 0 4 0x28000>;
/* firmware Disp_Index, the dual-pipe endpoint ID */
Expand Down Expand Up @@ -56,6 +57,7 @@
mboxes = <&dcpext1_mbox>;
mbox-names = "mbox";
iommus = <&dcpext1_dart 23>;
apple,hdcp-channels = <9 10>;
/* guessed, as dcpext0 */
apple,bw-scratch = <&pmgr_dcp 0 4 0x30000>;
apple,dcp-endpoint = <2>;
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/apple/t604x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@
mboxes = <&dcp_mbox>;
mbox-names = "mbox";
iommus = <&dcp_dart 23>;
apple,hdcp-channels = <5 6>;
apple,bw-scratch = <&pmgr_dcp 0 4 0x20000>;
apple,iomfb-surfaces = <1 1 0 0>;
/* the boot loader describes the piodma's regions with 2+2 cells */
Expand Down
2 changes: 2 additions & 0 deletions arch/arm64/boot/dts/apple/t8112.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@
mboxes = <&dcp_mbox>;
mbox-names = "mbox";
iommus = <&dcp_dart 5 0x8 0x00000000 0x7 0xffff0000>;
apple,hdcp-channels = <5 6>;

/* the ADT has 2 additional regs which seems to be unused */
reg-names = "coproc", "disp-0", "disp-1", "disp-2", "disp-3";
Expand Down Expand Up @@ -2007,6 +2008,7 @@
mboxes = <&dcpext_mbox>;
mbox-names = "mbox";
iommus = <&dcpext_dart 5 0x8 0x00000000 0x7 0xffff0000>;
apple,hdcp-channels = <7 8>;
phandle = <&dcpext>;

/* the ADT has 2 additional regs which seems to be unused */
Expand Down
15 changes: 15 additions & 0 deletions drivers/gpu/drm/apple/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ config DRM_APPLE_CEC
dcpav-cec-interface-epic service. Say Y here to expose a standard
Linux /dev/cecX adapter bound to the built-in HDMI connector.

config DRM_APPLE_HDCP
bool "HDCP 2.2 content protection on external outputs"
default y
depends on DRM_APPLE
select DRM_DISPLAY_HELPER
select DRM_DISPLAY_HDCP_HELPER
help
Support the standard "Content Protection" and "HDCP Content Type"
connector properties on external DisplayPort, HDMI and USB-C
outputs. The SEP holds the transmitter's keys and does the HDCP 2.2
cryptography; DCP carries the messages to the receiver. The
property is attached on display processors whose device tree node
has "apple,hdcp-channels", with the SEP HDCP service
(APPLE_SEP_HDCP_INTERFACE) built in.

config DRM_APPLE_AUDIO
bool "DisplayPort/HDMI Audio support"
default y
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/apple/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ appledrm-y += epic/dpavservep.o
appledrm-y += epic/panelavep.o
appledrm-y += plane.o
appledrm-y += dcp-indicator.o
appledrm-$(CONFIG_DRM_APPLE_HDCP) += dcp-hdcp.o dcp-hdcp-tx.o


appledrm-$(CONFIG_TRACING) += trace.o
Expand All @@ -50,6 +51,8 @@ obj-$(CONFIG_DRM_APPLE_KUNIT_TEST) += afk_test.o
obj-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp_backlight_test.o
obj-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp-indicator-test.o
obj-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp-announce-test.o
obj-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp-hdcp-test.o
obj-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp-hdcp-wire-test.o

obj-$(CONFIG_DRM_APPLE_KUNIT_TEST) += afk-service-test.o
obj-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp_cec_test.o
Expand Down
34 changes: 24 additions & 10 deletions drivers/gpu/drm/apple/afk.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <kunit/visibility.h>

#include "afk.h"
#include "dcp-hdcp-drv.h"
#include "afkv2-codec.h"
#include "afk_reply.h"
#include "trace.h"
Expand Down Expand Up @@ -458,7 +459,7 @@ afk_match_service(struct apple_dcp_afkep *ep, const char *name)
return ops;
}

return NULL;
return dcp_hdcp_match_service(ep, name, false);
}

static struct apple_epic_service *afk_epic_find_service(struct apple_dcp_afkep *ep,
Expand Down Expand Up @@ -830,6 +831,7 @@ afk_compact_match_service(struct apple_dcp_afkep *ep, const char *name)
const struct apple_epic_service_ops *ops, *any = NULL;
const char *service_name;
size_t len;
bool cut;

if (!name[0] || !ep->ops)
return NULL;
Expand All @@ -856,13 +858,14 @@ afk_compact_match_service(struct apple_dcp_afkep *ep, const char *name)
}

/* An announcement that filled its field may have lost its end. */
if (strlen(name) < AFK_COMPACT_NAME_LEN - 1)
return any;
for (ops = ep->ops; ops->name[0]; ops++)
if (afk_compact_cut_of(ops, service_name))
return ops;
cut = strlen(name) >= AFK_COMPACT_NAME_LEN - 1;
if (cut)
for (ops = ep->ops; ops->name[0]; ops++)
if (afk_compact_cut_of(ops, service_name))
return ops;

return any;
/* The HDCP services, by name, wherever they are announced. */
return dcp_hdcp_match_service(ep, service_name, cut) ?: any;
}

/*
Expand Down Expand Up @@ -1901,9 +1904,15 @@ static void afk_recv_handle_init(struct apple_dcp_afkep *ep, u32 channel,
}
}

if (ep->match_epic_name)
/*
* The HDCP services go by their EPIC name: their provider classes are
* shared with other services (the DP device class also names the AV
* device, the interface class names the port controllers).
*/
ops = dcp_hdcp_match_service(ep, epic_name, false);
if (!ops && ep->match_epic_name)
ops = afk_match_service(ep, epic_name);
else
else if (!ops)
ops = afk_match_service(ep, service_name);
if (dcp_is_ext26(ep->dcp))
dev_dbg(ep->dcp->dev,
Expand Down Expand Up @@ -3015,7 +3024,12 @@ static int afk_send_epic_token(struct apple_dcp_afkep *ep, u32 channel, u16 tag,
if (ep->wire_v2) {
if (!channel || channel > U16_MAX || tag > U8_MAX || payload_len > SZ_1M)
return -EINVAL;
if (ecat == EPIC_CAT_REPORT) {
if (ecat == EPIC_CAT_REPORT && stype == EPIC_SUBTYPE_STD_SERVICE) {
/* A service report with its data (an HDCP session's progress). */
if (!payload_len)
return -EINVAL;
v2_category = AFKV2_REPORT;
} else if (ecat == EPIC_CAT_REPORT) {
if ((stype != AFKV2_OPEN && stype != AFKV2_CLOSE) || payload_len)
return -EOPNOTSUPP;
v2_flags = 1;
Expand Down
18 changes: 18 additions & 0 deletions drivers/gpu/drm/apple/apple_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "apple_resume.h"
#include "dcp-hdr-metadata.h"
#include "dcp.h"
#include "dcp-hdcp-drv.h"
#include "plane.h"
#include "iomfb_m4.h"
#include "t8132_ext_drm.h"
Expand Down Expand Up @@ -1035,6 +1036,8 @@ static void apple_atomic_commit_tail(struct drm_atomic_commit *state)
DRM_PLANE_COMMIT_ACTIVE_ONLY);
drm_atomic_helper_fake_vblank(state);
drm_atomic_helper_commit_hw_done(state);
/* Content Protection requests go to the display processors' queues. */
dcp_hdcp_commit(state);
drm_atomic_helper_wait_for_flip_done(state->dev, state);
apple_fail_lost_flips(state);
drm_atomic_helper_cleanup_planes(state->dev, state);
Expand Down Expand Up @@ -1150,6 +1153,7 @@ static int apple_connector_atomic_check(struct drm_connector *conn,
const struct drm_property_blob *blob = new->hdr_output_metadata;
struct drm_crtc_state *crtc_state;

dcp_hdcp_atomic_check(conn, state);
if (blob && (blob->length != sizeof(struct hdr_output_metadata) ||
!dcp_hdr_is_type1(blob->data)))
return -EINVAL;
Expand Down Expand Up @@ -1356,6 +1360,9 @@ static int apple_connector_create(struct drm_device *drm,
dcp_ext_color_props_supported(dcp));
if (ret)
goto err_cleanup;
ret = dcp_hdcp_attach_connector(connector, &dcp, 1, connector_type);
if (ret)
goto err_cleanup;

connector->base.polled = DRM_CONNECTOR_POLL_HPD;
connector->connected = false;
Expand Down Expand Up @@ -1718,6 +1725,17 @@ static int apple_probe_typec_ports(struct drm_device *drm,
connector->connected = false;
connector->dcp = NULL;

/* Content Protection where a pipeline that can drive the port has HDCP. */
for (i = 0; i < num_dcp; i++) {
if (pipeline ? dcp[i] != pipeline :
!dcp_typec_port_has_candidate(port_idx, dcp[i]))
continue;
ret = dcp_hdcp_attach_connector(connector, &dcp[i], 1,
DRM_MODE_CONNECTOR_DisplayPort);
if (ret)
return ret;
}

/*
* One encoder per connector, covering its allowed pipelines.
* T6050 connectors each cover exactly one. Attaching several
Expand Down
9 changes: 9 additions & 0 deletions drivers/gpu/drm/apple/connector.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ struct apple_connector {
* chosen one; -1 until then, and nothing is sent.
*/
int bl_level;

/*
* Content Protection (dcp-hdcp-drv.h): the property is attached, and
* what the last commit asked for. Written by the commit tail, read by
* the display processor that drives the connector.
*/
bool hdcp_attached;
bool hdcp_want;
u8 hdcp_type;
};

#define to_apple_connector(x) container_of(x, struct apple_connector, base)
Expand Down
79 changes: 79 additions & 0 deletions drivers/gpu/drm/apple/dcp-hdcp-drv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
/* Copyright 2026 Ryan Murray */
#ifndef __APPLE_DCP_HDCP_DRV_H__
#define __APPLE_DCP_HDCP_DRV_H__

#include <linux/kconfig.h>
#include <linux/types.h>

struct apple_connector;
struct apple_dcp;
struct apple_dcp_afkep;
struct apple_epic_service_ops;
struct drm_atomic_commit;
struct drm_connector;
struct platform_device;

/*
* HDCP 2.2 on the display processors' external outputs: the DCP services
* (dcp-hdcp-wire.h), the transmitter (dcp-hdcp-tx.h) and the Content
* Protection policy (dcp-hdcp.h), joined to the connector properties.
*/
/* Whether something already drives @endpoint (dcp.c). */
bool dcp_endpoint_routed(struct apple_dcp *dcp, u8 endpoint);

#if IS_ENABLED(CONFIG_DRM_APPLE_HDCP)
/* A display processor's HDCP state, if it has an HDCP channel; idempotent. */
struct dcp_hdcp *dcp_hdcp_init(struct apple_dcp *dcp);
void dcp_hdcp_fini(struct apple_dcp *dcp);
/* Starts the DP device and HDCP interface endpoints when no other path did. */
void dcp_hdcp_start_endpoints(struct apple_dcp *dcp);
/* Routes the endpoints this file started. */
struct apple_dcp_afkep *dcp_hdcp_route(struct apple_dcp *dcp, u32 endpoint);
/* The HDCP services, matched by name ahead of a catch-all. */
const struct apple_epic_service_ops *
dcp_hdcp_match_service(struct apple_dcp_afkep *ep, const char *service_name,
bool cut);
/* Hotplug, power off or on, suspend, a new route: a new link generation. */
void dcp_hdcp_link_changed(struct apple_dcp *dcp);
/* The same, and its teardown finished before returning (suspend, DPMS off). */
void dcp_hdcp_quiesce(struct apple_dcp *dcp);

int dcp_hdcp_attach_connector(struct apple_connector *connector,
struct platform_device **dcps, unsigned int n,
int connector_type);
void dcp_hdcp_atomic_check(struct drm_connector *conn,
struct drm_atomic_commit *state);
void dcp_hdcp_commit(struct drm_atomic_commit *state);
#else
static inline struct dcp_hdcp *dcp_hdcp_init(struct apple_dcp *dcp) { return NULL; }
static inline void dcp_hdcp_fini(struct apple_dcp *dcp) { }
static inline void dcp_hdcp_start_endpoints(struct apple_dcp *dcp) { }
static inline struct apple_dcp_afkep *dcp_hdcp_route(struct apple_dcp *dcp,
u32 endpoint)
{
return NULL;
}

static inline const struct apple_epic_service_ops *
dcp_hdcp_match_service(struct apple_dcp_afkep *ep, const char *service_name,
bool cut)
{
return NULL;
}

static inline void dcp_hdcp_link_changed(struct apple_dcp *dcp) { }
static inline void dcp_hdcp_quiesce(struct apple_dcp *dcp) { }
static inline int dcp_hdcp_attach_connector(struct apple_connector *connector,
struct platform_device **dcps,
unsigned int n, int connector_type)
{
return 0;
}

static inline void dcp_hdcp_atomic_check(struct drm_connector *conn,
struct drm_atomic_commit *state) { }
static inline void dcp_hdcp_commit(struct drm_atomic_commit *state) { }
#endif

#endif /* __APPLE_DCP_HDCP_DRV_H__ */
Loading
Loading