// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
/*
 * Copyright (c) 2023 MediaTek Inc. All rights reserved.
 */

#define pr_fmt(fmt) "dprx: " fmt

#include "mtk_srccap_dprx.h"
#include "hwreg_srccap_dprx_edid.h"

int mtk_dprx_edid_write(struct dprx_device *dev,
			enum v4l2_srccap_input_source port,
			u8 *edid,
			u16 size)
{
	DPRx_ID dprx_id;

	if (!edid)
		return -EINVAL;

	if (!mtk_dprx_is_valid_input_port(dev, port))
		return -1;

	dprx_id = mtk_dprx_input_to_dprx_id(dev, port);

	KDrv_SRCCAP_DPRx_edid_loadedid(dprx_id, size, edid);

	return 0;
}

int mtk_dprx_edid_read(struct dprx_device *dev,
		       enum v4l2_srccap_input_source port,
		       u8 *edid,
		       u16 size)
{
	DPRx_ID dprx_id;

	if (!edid)
		return -EINVAL;

	if (!mtk_dprx_is_valid_input_port(dev, port))
		return -1;

	dprx_id = mtk_dprx_input_to_dprx_id(dev, port);

	KDrv_SRCCAP_DPRx_edid_readedid(dprx_id, edid, size);

	return 0;
}
