mirror of
https://github.com/torvalds/linux.git
synced 2024-12-26 12:52:30 +00:00
4e855a6efa
Add v4l2 layer encoder driver for MT8173 Signed-off-by: Tiffany Lin <tiffany.lin@mediatek.com> [hans.verkuil@cisco.com: drop unnecessary ARM || ARM64 dependency] Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
138 lines
3.2 KiB
C
138 lines
3.2 KiB
C
/*
|
|
* Copyright (c) 2016 MediaTek Inc.
|
|
* Author: Tiffany Lin <tiffany.lin@mediatek.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include <linux/clk.h>
|
|
#include <linux/of_address.h>
|
|
#include <linux/of_platform.h>
|
|
#include <linux/pm_runtime.h>
|
|
#include <soc/mediatek/smi.h>
|
|
|
|
#include "mtk_vcodec_enc_pm.h"
|
|
#include "mtk_vcodec_util.h"
|
|
#include "mtk_vpu.h"
|
|
|
|
|
|
int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *mtkdev)
|
|
{
|
|
struct device_node *node;
|
|
struct platform_device *pdev;
|
|
struct device *dev;
|
|
struct mtk_vcodec_pm *pm;
|
|
int ret = 0;
|
|
|
|
pdev = mtkdev->plat_dev;
|
|
pm = &mtkdev->pm;
|
|
memset(pm, 0, sizeof(struct mtk_vcodec_pm));
|
|
pm->mtkdev = mtkdev;
|
|
pm->dev = &pdev->dev;
|
|
dev = &pdev->dev;
|
|
|
|
node = of_parse_phandle(dev->of_node, "mediatek,larb", 0);
|
|
if (!node) {
|
|
mtk_v4l2_err("no mediatek,larb found");
|
|
return -1;
|
|
}
|
|
pdev = of_find_device_by_node(node);
|
|
if (!pdev) {
|
|
mtk_v4l2_err("no mediatek,larb device found");
|
|
return -1;
|
|
}
|
|
pm->larbvenc = &pdev->dev;
|
|
|
|
node = of_parse_phandle(dev->of_node, "mediatek,larb", 1);
|
|
if (!node) {
|
|
mtk_v4l2_err("no mediatek,larb found");
|
|
return -1;
|
|
}
|
|
|
|
pdev = of_find_device_by_node(node);
|
|
if (!pdev) {
|
|
mtk_v4l2_err("no mediatek,larb device found");
|
|
return -1;
|
|
}
|
|
|
|
pm->larbvenclt = &pdev->dev;
|
|
pdev = mtkdev->plat_dev;
|
|
pm->dev = &pdev->dev;
|
|
|
|
pm->vencpll_d2 = devm_clk_get(&pdev->dev, "venc_sel_src");
|
|
if (pm->vencpll_d2 == NULL) {
|
|
mtk_v4l2_err("devm_clk_get vencpll_d2 fail");
|
|
ret = -1;
|
|
}
|
|
|
|
pm->venc_sel = devm_clk_get(&pdev->dev, "venc_sel");
|
|
if (pm->venc_sel == NULL) {
|
|
mtk_v4l2_err("devm_clk_get venc_sel fail");
|
|
ret = -1;
|
|
}
|
|
|
|
pm->univpll1_d2 = devm_clk_get(&pdev->dev, "venc_lt_sel_src");
|
|
if (pm->univpll1_d2 == NULL) {
|
|
mtk_v4l2_err("devm_clk_get univpll1_d2 fail");
|
|
ret = -1;
|
|
}
|
|
|
|
pm->venc_lt_sel = devm_clk_get(&pdev->dev, "venc_lt_sel");
|
|
if (pm->venc_lt_sel == NULL) {
|
|
mtk_v4l2_err("devm_clk_get venc_lt_sel fail");
|
|
ret = -1;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
void mtk_vcodec_release_enc_pm(struct mtk_vcodec_dev *mtkdev)
|
|
{
|
|
}
|
|
|
|
|
|
void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm)
|
|
{
|
|
int ret;
|
|
|
|
ret = clk_prepare_enable(pm->venc_sel);
|
|
if (ret)
|
|
mtk_v4l2_err("clk_prepare_enable fail %d", ret);
|
|
|
|
ret = clk_set_parent(pm->venc_sel, pm->vencpll_d2);
|
|
if (ret)
|
|
mtk_v4l2_err("clk_set_parent fail %d", ret);
|
|
|
|
ret = clk_prepare_enable(pm->venc_lt_sel);
|
|
if (ret)
|
|
mtk_v4l2_err("clk_prepare_enable fail %d", ret);
|
|
|
|
ret = clk_set_parent(pm->venc_lt_sel, pm->univpll1_d2);
|
|
if (ret)
|
|
mtk_v4l2_err("clk_set_parent fail %d", ret);
|
|
|
|
ret = mtk_smi_larb_get(pm->larbvenc);
|
|
if (ret)
|
|
mtk_v4l2_err("mtk_smi_larb_get larb3 fail %d", ret);
|
|
|
|
ret = mtk_smi_larb_get(pm->larbvenclt);
|
|
if (ret)
|
|
mtk_v4l2_err("mtk_smi_larb_get larb4 fail %d", ret);
|
|
|
|
}
|
|
|
|
void mtk_vcodec_enc_clock_off(struct mtk_vcodec_pm *pm)
|
|
{
|
|
mtk_smi_larb_put(pm->larbvenc);
|
|
mtk_smi_larb_put(pm->larbvenclt);
|
|
clk_disable_unprepare(pm->venc_lt_sel);
|
|
clk_disable_unprepare(pm->venc_sel);
|
|
}
|