Skip to content

Commit 5774a42

Browse files
kbinghampopcornmix
authored andcommitted
staging: vc04_services: bcm2835-v4l2-codec: Register with vchiq_bus_type
Signed-off-by: Kieran Bingham <[email protected]>
1 parent 4a73979 commit 5774a42

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <linux/timer.h>
2727
#include <linux/sched.h>
2828
#include <linux/slab.h>
29-
#include <linux/platform_device.h>
3029
#include <linux/syscalls.h>
3130

3231
#include <media/v4l2-mem2mem.h>
@@ -36,6 +35,8 @@
3635
#include <media/v4l2-event.h>
3736
#include <media/videobuf2-dma-contig.h>
3837

38+
#include "../interface/vchiq_arm/vchiq_bus.h"
39+
3940
#include "../vchiq-mmal/mmal-encodings.h"
4041
#include "../vchiq-mmal/mmal-msg.h"
4142
#include "../vchiq-mmal/mmal-parameters.h"
@@ -674,7 +675,7 @@ struct bcm2835_codec_q_data {
674675
};
675676

676677
struct bcm2835_codec_dev {
677-
struct platform_device *pdev;
678+
struct vchiq_device *device;
678679

679680
/* v4l2 devices */
680681
struct v4l2_device v4l2_dev;
@@ -731,7 +732,7 @@ struct bcm2835_codec_ctx {
731732
};
732733

733734
struct bcm2835_codec_driver {
734-
struct platform_device *pdev;
735+
struct vchiq_device *device;
735736
struct media_device mdev;
736737

737738
struct bcm2835_codec_dev *encode;
@@ -3232,7 +3233,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
32323233
src_vq->buf_struct_size = sizeof(struct m2m_mmal_buffer);
32333234
src_vq->ops = &bcm2835_codec_qops;
32343235
src_vq->mem_ops = &vb2_dma_contig_memops;
3235-
src_vq->dev = &ctx->dev->pdev->dev;
3236+
src_vq->dev = &ctx->dev->device->dev;
32363237
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
32373238
src_vq->lock = &ctx->dev->dev_mutex;
32383239

@@ -3246,7 +3247,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
32463247
dst_vq->buf_struct_size = sizeof(struct m2m_mmal_buffer);
32473248
dst_vq->ops = &bcm2835_codec_qops;
32483249
dst_vq->mem_ops = &vb2_dma_contig_memops;
3249-
dst_vq->dev = &ctx->dev->pdev->dev;
3250+
dst_vq->dev = &ctx->dev->device->dev;
32503251
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
32513252
dst_vq->lock = &ctx->dev->dev_mutex;
32523253

@@ -3678,7 +3679,7 @@ static int bcm2835_codec_get_supported_fmts(struct bcm2835_codec_dev *dev)
36783679
/* Assume at this stage that all encodings will be supported in V4L2.
36793680
* Any that aren't supported will waste a very small amount of memory.
36803681
*/
3681-
list = devm_kzalloc(&dev->pdev->dev,
3682+
list = devm_kzalloc(&dev->device->dev,
36823683
sizeof(struct bcm2835_codec_fmt) * num_encodings,
36833684
GFP_KERNEL);
36843685
if (!list) {
@@ -3719,7 +3720,7 @@ static int bcm2835_codec_get_supported_fmts(struct bcm2835_codec_dev *dev)
37193720
num_encodings = param_size / sizeof(u32);
37203721
}
37213722
/* Assume at this stage that all encodings will be supported in V4L2. */
3722-
list = devm_kzalloc(&dev->pdev->dev,
3723+
list = devm_kzalloc(&dev->device->dev,
37233724
sizeof(struct bcm2835_codec_fmt) * num_encodings,
37243725
GFP_KERNEL);
37253726
if (!list) {
@@ -3750,22 +3751,22 @@ static int bcm2835_codec_create(struct bcm2835_codec_driver *drv,
37503751
struct bcm2835_codec_dev **new_dev,
37513752
enum bcm2835_codec_role role)
37523753
{
3753-
struct platform_device *pdev = drv->pdev;
3754+
struct vchiq_device *device = drv->device;
37543755
struct bcm2835_codec_dev *dev;
37553756
struct video_device *vfd;
37563757
int function;
37573758
int video_nr;
37583759
int ret;
37593760

3760-
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
3761+
dev = devm_kzalloc(&device->dev, sizeof(*dev), GFP_KERNEL);
37613762
if (!dev)
37623763
return -ENOMEM;
37633764

3764-
dev->pdev = pdev;
3765+
dev->device = device;
37653766

37663767
dev->role = role;
37673768

3768-
ret = vchiq_mmal_init(&dev->instance);
3769+
ret = vchiq_mmal_init(&device->dev, &dev->instance);
37693770
if (ret)
37703771
return ret;
37713772

@@ -3785,7 +3786,7 @@ static int bcm2835_codec_create(struct bcm2835_codec_driver *drv,
37853786
vfd->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
37863787
vfd->v4l2_dev->mdev = &drv->mdev;
37873788

3788-
ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
3789+
ret = v4l2_device_register(&device->dev, &dev->v4l2_dev);
37893790
if (ret)
37903791
goto vchiq_finalise;
37913792

@@ -3891,24 +3892,24 @@ static int bcm2835_codec_destroy(struct bcm2835_codec_dev *dev)
38913892
return 0;
38923893
}
38933894

3894-
static int bcm2835_codec_probe(struct platform_device *pdev)
3895+
static int bcm2835_codec_probe(struct vchiq_device *device)
38953896
{
38963897
struct bcm2835_codec_driver *drv;
38973898
struct media_device *mdev;
38983899
int ret = 0;
38993900

3900-
drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
3901+
drv = devm_kzalloc(&device->dev, sizeof(*drv), GFP_KERNEL);
39013902
if (!drv)
39023903
return -ENOMEM;
39033904

3904-
drv->pdev = pdev;
3905+
drv->device = device;
39053906
mdev = &drv->mdev;
3906-
mdev->dev = &pdev->dev;
3907+
mdev->dev = &device->dev;
39073908

39083909
strscpy(mdev->model, bcm2835_codec_videodev.name, sizeof(mdev->model));
39093910
strscpy(mdev->serial, "0000", sizeof(mdev->serial));
3910-
snprintf(mdev->bus_info, sizeof(mdev->bus_info), "platform:%s",
3911-
pdev->name);
3911+
snprintf(mdev->bus_info, sizeof(mdev->bus_info), "vchiq:%s",
3912+
MEM2MEM_NAME);
39123913

39133914
/* This should return the vgencmd version information or such .. */
39143915
mdev->hw_revision = 1;
@@ -3938,7 +3939,7 @@ static int bcm2835_codec_probe(struct platform_device *pdev)
39383939
if (media_device_register(mdev) < 0)
39393940
goto out;
39403941

3941-
platform_set_drvdata(pdev, drv);
3942+
vchiq_set_drvdata(device, drv);
39423943

39433944
return 0;
39443945

@@ -3966,9 +3967,9 @@ static int bcm2835_codec_probe(struct platform_device *pdev)
39663967
return ret;
39673968
}
39683969

3969-
static int bcm2835_codec_remove(struct platform_device *pdev)
3970+
static void bcm2835_codec_remove(struct vchiq_device *device)
39703971
{
3971-
struct bcm2835_codec_driver *drv = platform_get_drvdata(pdev);
3972+
struct bcm2835_codec_driver *drv = vchiq_get_drvdata(device);
39723973

39733974
media_device_unregister(&drv->mdev);
39743975

@@ -3983,11 +3984,9 @@ static int bcm2835_codec_remove(struct platform_device *pdev)
39833984
bcm2835_codec_destroy(drv->decode);
39843985

39853986
media_device_cleanup(&drv->mdev);
3986-
3987-
return 0;
39883987
}
39893988

3990-
static struct platform_driver bcm2835_v4l2_codec_driver = {
3989+
static struct vchiq_driver bcm2835_v4l2_codec_driver = {
39913990
.probe = bcm2835_codec_probe,
39923991
.remove = bcm2835_codec_remove,
39933992
.driver = {
@@ -3996,10 +3995,10 @@ static struct platform_driver bcm2835_v4l2_codec_driver = {
39963995
},
39973996
};
39983997

3999-
module_platform_driver(bcm2835_v4l2_codec_driver);
3998+
module_vchiq_driver(bcm2835_v4l2_codec_driver);
40003999

40014000
MODULE_DESCRIPTION("BCM2835 codec V4L2 driver");
40024001
MODULE_AUTHOR("Dave Stevenson, <[email protected]>");
40034002
MODULE_LICENSE("GPL");
40044003
MODULE_VERSION("0.0.1");
4005-
MODULE_ALIAS("platform:bcm2835-codec");
4004+
MODULE_ALIAS("vchiq:bcm2835-codec");

0 commit comments

Comments
 (0)