video: driver: implement module remove function
Implement remove function to unregister video device, unregister v4l2 device, remove sysfs group, deinit irq, platform, dt, core. Change-Id: Ib713b0b66500aafcfb5f0500b9ce7285b9640311 Signed-off-by: Darshana Patil <darshana@codeaurora.org>
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
parent
3aa92663a7
commit
843858405f
@@ -9,5 +9,6 @@
|
||||
#include "msm_vidc_core.h"
|
||||
|
||||
int msm_vidc_init_platform_waipio(struct msm_vidc_core *core);
|
||||
int msm_vidc_deinit_platform_waipio(struct msm_vidc_core *core);
|
||||
|
||||
#endif // _MSM_VIDC_WAIPIO_H_
|
||||
|
@@ -354,3 +354,9 @@ int msm_vidc_init_platform_waipio(struct msm_vidc_core *core)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int msm_vidc_deinit_platform_waipio(struct msm_vidc_core *core)
|
||||
{
|
||||
/* do nothing */
|
||||
return 0;
|
||||
}
|
||||
|
@@ -13,3 +13,4 @@ int msm_vidc_init_iris2(struct msm_vidc_core *core);
|
||||
// return -EINVAL;
|
||||
//}
|
||||
//#endif
|
||||
int msm_vidc_deinit_iris2(struct msm_vidc_core *core);
|
||||
|
@@ -519,3 +519,9 @@ int msm_vidc_init_iris2(struct msm_vidc_core *core)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int msm_vidc_deinit_iris2(struct msm_vidc_core *core)
|
||||
{
|
||||
/* do nothing */
|
||||
return 0;
|
||||
}
|
||||
|
@@ -485,7 +485,7 @@ static int vb2_buffer_to_driver(struct vb2_buffer *vb2,
|
||||
buf->data_offset = vb2->planes[0].data_offset;
|
||||
buf->data_size = vb2->planes[0].bytesused;
|
||||
buf->buffer_size = vb2->planes[0].length;
|
||||
buf->timestamp = do_div(vb2->timestamp, NSEC_PER_USEC);
|
||||
buf->timestamp = vb2->timestamp;
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -1003,7 +1003,7 @@ int msm_vidc_vb2_buffer_done(struct msm_vidc_inst *inst,
|
||||
}
|
||||
vbuf = to_vb2_v4l2_buffer(vb2);
|
||||
vbuf->flags = buf->flags;
|
||||
vb2->timestamp = buf->timestamp * NSEC_PER_USEC;
|
||||
vb2->timestamp = buf->timestamp;
|
||||
vb2->planes[0].bytesused = buf->data_size;
|
||||
vb2_buffer_done(vb2, VB2_BUF_STATE_DONE);
|
||||
|
||||
|
@@ -88,6 +88,34 @@ static int msm_vidc_init_ops(struct msm_vidc_core *core)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int msm_vidc_deinit_platform(struct platform_device *pdev)
|
||||
{
|
||||
struct msm_vidc_core *core;
|
||||
|
||||
if (!pdev) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
core = dev_get_drvdata(&pdev->dev);
|
||||
if (!core) {
|
||||
d_vpr_e("%s: core not found in device %s",
|
||||
dev_name(&pdev->dev));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
|
||||
if (of_device_is_compatible(pdev->dev.of_node, "qcom,msm-vidc"))
|
||||
msm_vidc_deinit_iris2(core);
|
||||
|
||||
if (of_device_is_compatible(pdev->dev.of_node, "qcom,msm-vidc"))
|
||||
msm_vidc_deinit_platform_waipio(core);
|
||||
|
||||
kfree(core->platform);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int msm_vidc_init_platform(struct platform_device *pdev)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -104,7 +132,7 @@ int msm_vidc_init_platform(struct platform_device *pdev)
|
||||
core = dev_get_drvdata(&pdev->dev);
|
||||
if (!core) {
|
||||
d_vpr_e("%s: core not found in device %s",
|
||||
dev_name(&pdev->dev));
|
||||
dev_name(&pdev->dev));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -134,8 +162,3 @@ int msm_vidc_init_platform(struct platform_device *pdev)
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int msm_vidc_deinit_platform(struct platform_device *pdev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@@ -20,13 +20,33 @@
|
||||
|
||||
#define BASE_DEVICE_NUMBER 32
|
||||
|
||||
static int msm_vidc_deinit_irq(struct msm_vidc_core *core)
|
||||
{
|
||||
struct msm_vidc_dt *dt;
|
||||
|
||||
if (!core || !core->pdev || !core->dt) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
dt = core->dt;
|
||||
d_vpr_h("%s: reg_base = %pa, reg_size = %#x\n",
|
||||
__func__, &dt->register_base, dt->register_size);
|
||||
|
||||
if (dt->irq)
|
||||
free_irq(dt->irq, core);
|
||||
dt->irq = 0;
|
||||
|
||||
if (core->register_base_addr)
|
||||
devm_iounmap(&core->pdev->dev, core->register_base_addr);
|
||||
core->register_base_addr = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msm_vidc_init_irq(struct msm_vidc_core *core)
|
||||
{
|
||||
int rc = 0;
|
||||
struct msm_vidc_dt *dt;
|
||||
|
||||
d_vpr_e("%s()\n", __func__);
|
||||
|
||||
if (!core || !core->pdev || !core->dt) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
@@ -38,6 +58,7 @@ static int msm_vidc_init_irq(struct msm_vidc_core *core)
|
||||
if (!core->register_base_addr) {
|
||||
d_vpr_e("could not map reg addr %pa of size %d\n",
|
||||
&dt->register_base, dt->register_size);
|
||||
rc = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -55,9 +76,7 @@ static int msm_vidc_init_irq(struct msm_vidc_core *core)
|
||||
return 0;
|
||||
|
||||
exit:
|
||||
if (core->device_workq)
|
||||
destroy_workqueue(core->device_workq);
|
||||
|
||||
msm_vidc_deinit_irq(core);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -75,12 +94,31 @@ static const struct of_device_id msm_vidc_dt_match[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, msm_vidc_dt_match);
|
||||
|
||||
|
||||
void msm_vidc_release_video_device(struct video_device *vdev)
|
||||
static void msm_vidc_release_video_device(struct video_device *vdev)
|
||||
{
|
||||
d_vpr_e("%s:\n", __func__);
|
||||
}
|
||||
|
||||
static void msm_vidc_unregister_video_device(struct msm_vidc_core *core,
|
||||
enum msm_vidc_domain_type type)
|
||||
{
|
||||
int index;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
|
||||
if (type == MSM_VIDC_DECODER)
|
||||
index = 0;
|
||||
else if (type == MSM_VIDC_ENCODER)
|
||||
index = 1;
|
||||
else
|
||||
return;
|
||||
|
||||
//rc = device_create_file(&core->vdev[index].vdev.dev, &dev_attr_link_name);
|
||||
video_set_drvdata(&core->vdev[index].vdev, NULL);
|
||||
video_unregister_device(&core->vdev[index].vdev);
|
||||
//memset vdev to 0
|
||||
}
|
||||
|
||||
static int msm_vidc_register_video_device(struct msm_vidc_core *core,
|
||||
enum msm_vidc_domain_type type, int nr)
|
||||
{
|
||||
@@ -126,6 +164,28 @@ static int msm_vidc_register_video_device(struct msm_vidc_core *core,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msm_vidc_deinitialize_core(struct msm_vidc_core *core)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (!core) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
|
||||
mutex_destroy(&core->lock);
|
||||
core->state = MSM_VIDC_CORE_DEINIT;
|
||||
|
||||
if (core->pm_workq)
|
||||
destroy_workqueue(core->pm_workq);
|
||||
|
||||
if (core->device_workq)
|
||||
destroy_workqueue(core->device_workq);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int msm_vidc_initialize_core(struct msm_vidc_core *core)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -280,42 +340,35 @@ static int msm_vidc_probe(struct platform_device *pdev)
|
||||
|
||||
static int msm_vidc_remove(struct platform_device *pdev)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
|
||||
/*
|
||||
struct msm_vidc_core *core;
|
||||
|
||||
if (!pdev) {
|
||||
d_vpr_e("%s: invalid input %pK", __func__, pdev);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
core = dev_get_drvdata(&pdev->dev);
|
||||
if (!core) {
|
||||
d_vpr_e("%s: invalid core", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (core->vidc_core_workq)
|
||||
destroy_workqueue(core->vidc_core_workq);
|
||||
vidc_hfi_deinitialize(core->hfi_type, core->device);
|
||||
device_remove_file(&core->vdev[MSM_VIDC_ENCODER].vdev.dev,
|
||||
&dev_attr_link_name);
|
||||
video_unregister_device(&core->vdev[MSM_VIDC_ENCODER].vdev);
|
||||
device_remove_file(&core->vdev[MSM_VIDC_DECODER].vdev.dev,
|
||||
&dev_attr_link_name);
|
||||
video_unregister_device(&core->vdev[MSM_VIDC_DECODER].vdev);
|
||||
v4l2_device_unregister(&core->v4l2_dev);
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
|
||||
//msm_vidc_free_platform_resources(&core->resources);
|
||||
msm_vidc_unregister_video_device(core, MSM_VIDC_ENCODER);
|
||||
msm_vidc_unregister_video_device(core, MSM_VIDC_DECODER);
|
||||
//device_remove_file(&core->vdev[MSM_VIDC_ENCODER].vdev.dev,
|
||||
//&dev_attr_link_name);
|
||||
//device_remove_file(&core->vdev[MSM_VIDC_DECODER].vdev.dev,
|
||||
//&dev_attr_link_name);
|
||||
v4l2_device_unregister(&core->v4l2_dev);
|
||||
sysfs_remove_group(&pdev->dev.kobj, &msm_vidc_core_attr_group);
|
||||
msm_vidc_deinit_irq(core);
|
||||
msm_vidc_deinit_platform(pdev);
|
||||
msm_vidc_deinit_dt(pdev);
|
||||
msm_vidc_deinitialize_core(core);
|
||||
dev_set_drvdata(&pdev->dev, NULL);
|
||||
mutex_destroy(&core->lock);
|
||||
kfree(core);
|
||||
*/
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct platform_driver msm_vidc_driver = {
|
||||
|
Reference in New Issue
Block a user