mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-02 12:10:23 -04:00
media: mtk-vcodec: Get rid of mtk_smi_larb_get/put
MediaTek IOMMU has already added the device_link between the consumer and smi-larb device. If the vcodec devices call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. CC: Irui Wang <irui.wang@mediatek.com> Signed-off-by: Yong Wu <yong.wu@mediatek.com> Reviewed-by: Evan Green <evgreen@chromium.org> Acked-by: Tiffany Lin <tiffany.lin@mediatek.com> Reviewed-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
ce6c24baaa
commit
bf82757055
@@ -450,7 +450,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
|
||||
destroy_workqueue(dev->core_workqueue);
|
||||
err_res:
|
||||
pm_runtime_disable(dev->pm.dev);
|
||||
put_device(dev->pm.larbvdec);
|
||||
err_dec_pm:
|
||||
mtk_vcodec_fw_release(dev->fw_handler);
|
||||
return ret;
|
||||
@@ -494,7 +493,6 @@ static int mtk_vcodec_dec_remove(struct platform_device *pdev)
|
||||
|
||||
v4l2_device_unregister(&dev->v4l2_dev);
|
||||
pm_runtime_disable(dev->pm.dev);
|
||||
put_device(dev->pm.larbvdec);
|
||||
mtk_vcodec_fw_release(dev->fw_handler);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,6 @@ static int mtk_vdec_hw_probe(struct platform_device *pdev)
|
||||
return 0;
|
||||
err:
|
||||
pm_runtime_disable(subdev_dev->pm.dev);
|
||||
put_device(subdev_dev->pm.larbvdec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <soc/mediatek/smi.h>
|
||||
|
||||
#include "mtk_vcodec_dec_hw.h"
|
||||
#include "mtk_vcodec_dec_pm.h"
|
||||
@@ -17,25 +16,11 @@
|
||||
|
||||
int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *pm)
|
||||
{
|
||||
struct device_node *node;
|
||||
struct platform_device *larb_pdev;
|
||||
struct mtk_vcodec_clk *dec_clk;
|
||||
struct mtk_vcodec_clk_info *clk_info;
|
||||
int i = 0, ret = 0;
|
||||
int i = 0, ret;
|
||||
|
||||
dec_clk = &pm->vdec_clk;
|
||||
node = of_parse_phandle(pdev->dev.of_node, "mediatek,larb", 0);
|
||||
if (!node) {
|
||||
mtk_v4l2_err("of_parse_phandle mediatek,larb fail!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
larb_pdev = of_find_device_by_node(node);
|
||||
of_node_put(node);
|
||||
if (WARN_ON(!larb_pdev))
|
||||
return -1;
|
||||
|
||||
pm->larbvdec = &larb_pdev->dev;
|
||||
pm->dev = &pdev->dev;
|
||||
|
||||
dec_clk->clk_num =
|
||||
@@ -44,14 +29,11 @@ int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *
|
||||
dec_clk->clk_info = devm_kcalloc(&pdev->dev,
|
||||
dec_clk->clk_num, sizeof(*clk_info),
|
||||
GFP_KERNEL);
|
||||
if (!dec_clk->clk_info) {
|
||||
ret = -ENOMEM;
|
||||
goto put_device;
|
||||
}
|
||||
if (!dec_clk->clk_info)
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
mtk_v4l2_err("Failed to get vdec clock count");
|
||||
ret = -EINVAL;
|
||||
goto put_device;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; i < dec_clk->clk_num; i++) {
|
||||
@@ -60,22 +42,18 @@ int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *
|
||||
"clock-names", i, &clk_info->clk_name);
|
||||
if (ret) {
|
||||
mtk_v4l2_err("Failed to get clock name id = %d", i);
|
||||
goto put_device;
|
||||
return ret;
|
||||
}
|
||||
clk_info->vcodec_clk = devm_clk_get(&pdev->dev,
|
||||
clk_info->clk_name);
|
||||
if (IS_ERR(clk_info->vcodec_clk)) {
|
||||
mtk_v4l2_err("devm_clk_get (%d)%s fail", i,
|
||||
clk_info->clk_name);
|
||||
ret = PTR_ERR(clk_info->vcodec_clk);
|
||||
goto put_device;
|
||||
return PTR_ERR(clk_info->vcodec_clk);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
put_device:
|
||||
put_device(pm->larbvdec);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtk_vcodec_init_dec_clk);
|
||||
|
||||
@@ -157,13 +135,7 @@ void mtk_vcodec_dec_clock_on(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
|
||||
}
|
||||
}
|
||||
|
||||
ret = mtk_smi_larb_get(pm->larbvdec);
|
||||
if (ret) {
|
||||
mtk_v4l2_err("mtk_smi_larb_get larbvdec fail %d", ret);
|
||||
goto error;
|
||||
}
|
||||
return;
|
||||
|
||||
error:
|
||||
for (i -= 1; i >= 0; i--)
|
||||
clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
|
||||
@@ -191,7 +163,6 @@ void mtk_vcodec_dec_clock_off(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
|
||||
}
|
||||
|
||||
dec_clk = &pm->vdec_clk;
|
||||
mtk_smi_larb_put(pm->larbvdec);
|
||||
for (i = dec_clk->clk_num - 1; i >= 0; i--)
|
||||
clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
|
||||
}
|
||||
|
||||
@@ -214,10 +214,7 @@ struct mtk_vcodec_clk {
|
||||
*/
|
||||
struct mtk_vcodec_pm {
|
||||
struct mtk_vcodec_clk vdec_clk;
|
||||
struct device *larbvdec;
|
||||
|
||||
struct mtk_vcodec_clk venc_clk;
|
||||
struct device *larbvenc;
|
||||
struct device *dev;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <media/v4l2-event.h>
|
||||
#include <media/v4l2-mem2mem.h>
|
||||
#include <media/videobuf2-dma-contig.h>
|
||||
#include <soc/mediatek/smi.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
|
||||
#include "mtk_vcodec_drv.h"
|
||||
|
||||
@@ -371,7 +371,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
|
||||
v4l2_device_unregister(&dev->v4l2_dev);
|
||||
err_res:
|
||||
pm_runtime_disable(dev->pm.dev);
|
||||
put_device(dev->pm.larbvenc);
|
||||
err_enc_pm:
|
||||
mtk_vcodec_fw_release(dev->fw_handler);
|
||||
return ret;
|
||||
@@ -461,7 +460,6 @@ static int mtk_vcodec_enc_remove(struct platform_device *pdev)
|
||||
|
||||
v4l2_device_unregister(&dev->v4l2_dev);
|
||||
pm_runtime_disable(dev->pm.dev);
|
||||
put_device(dev->pm.larbvenc);
|
||||
mtk_vcodec_fw_release(dev->fw_handler);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,57 +8,35 @@
|
||||
#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"
|
||||
|
||||
int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev)
|
||||
{
|
||||
struct device_node *node;
|
||||
struct platform_device *pdev;
|
||||
struct mtk_vcodec_pm *pm;
|
||||
struct mtk_vcodec_clk *enc_clk;
|
||||
struct mtk_vcodec_clk_info *clk_info;
|
||||
int ret = 0, i = 0;
|
||||
struct device *dev;
|
||||
int ret, i;
|
||||
|
||||
pdev = mtkdev->plat_dev;
|
||||
pm = &mtkdev->pm;
|
||||
memset(pm, 0, sizeof(struct mtk_vcodec_pm));
|
||||
pm->dev = &pdev->dev;
|
||||
dev = &pdev->dev;
|
||||
enc_clk = &pm->venc_clk;
|
||||
|
||||
node = of_parse_phandle(dev->of_node, "mediatek,larb", 0);
|
||||
if (!node) {
|
||||
mtk_v4l2_err("no mediatek,larb found");
|
||||
return -ENODEV;
|
||||
}
|
||||
pdev = of_find_device_by_node(node);
|
||||
of_node_put(node);
|
||||
if (!pdev) {
|
||||
mtk_v4l2_err("no mediatek,larb device found");
|
||||
return -ENODEV;
|
||||
}
|
||||
pm->larbvenc = &pdev->dev;
|
||||
pdev = mtkdev->plat_dev;
|
||||
pm->dev = &pdev->dev;
|
||||
|
||||
enc_clk->clk_num = of_property_count_strings(pdev->dev.of_node,
|
||||
"clock-names");
|
||||
if (enc_clk->clk_num > 0) {
|
||||
enc_clk->clk_info = devm_kcalloc(&pdev->dev,
|
||||
enc_clk->clk_num, sizeof(*clk_info),
|
||||
GFP_KERNEL);
|
||||
if (!enc_clk->clk_info) {
|
||||
ret = -ENOMEM;
|
||||
goto put_larbvenc;
|
||||
}
|
||||
if (!enc_clk->clk_info)
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
mtk_v4l2_err("Failed to get venc clock count");
|
||||
ret = -EINVAL;
|
||||
goto put_larbvenc;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; i < enc_clk->clk_num; i++) {
|
||||
@@ -67,23 +45,18 @@ int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev)
|
||||
"clock-names", i, &clk_info->clk_name);
|
||||
if (ret) {
|
||||
mtk_v4l2_err("venc failed to get clk name %d", i);
|
||||
goto put_larbvenc;
|
||||
return ret;
|
||||
}
|
||||
clk_info->vcodec_clk = devm_clk_get(&pdev->dev,
|
||||
clk_info->clk_name);
|
||||
if (IS_ERR(clk_info->vcodec_clk)) {
|
||||
mtk_v4l2_err("venc devm_clk_get (%d)%s fail", i,
|
||||
clk_info->clk_name);
|
||||
ret = PTR_ERR(clk_info->vcodec_clk);
|
||||
goto put_larbvenc;
|
||||
return PTR_ERR(clk_info->vcodec_clk);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
put_larbvenc:
|
||||
put_device(pm->larbvenc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm)
|
||||
@@ -100,11 +73,6 @@ void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm)
|
||||
}
|
||||
}
|
||||
|
||||
ret = mtk_smi_larb_get(pm->larbvenc);
|
||||
if (ret) {
|
||||
mtk_v4l2_err("mtk_smi_larb_get larb3 fail %d", ret);
|
||||
goto clkerr;
|
||||
}
|
||||
return;
|
||||
|
||||
clkerr:
|
||||
@@ -117,7 +85,6 @@ void mtk_vcodec_enc_clock_off(struct mtk_vcodec_pm *pm)
|
||||
struct mtk_vcodec_clk *enc_clk = &pm->venc_clk;
|
||||
int i = 0;
|
||||
|
||||
mtk_smi_larb_put(pm->larbvenc);
|
||||
for (i = enc_clk->clk_num - 1; i >= 0; i--)
|
||||
clk_disable_unprepare(enc_clk->clk_info[i].vcodec_clk);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user