vsp1_histo.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * vsp1_histo.h -- R-Car VSP1 Histogram API
  3. *
  4. * Copyright (C) 2016 Renesas Electronics Corporation
  5. * Copyright (C) 2016 Laurent Pinchart
  6. *
  7. * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. */
  14. #ifndef __VSP1_HISTO_H__
  15. #define __VSP1_HISTO_H__
  16. #include <linux/list.h>
  17. #include <linux/mutex.h>
  18. #include <linux/spinlock.h>
  19. #include <media/media-entity.h>
  20. #include <media/v4l2-dev.h>
  21. #include <media/videobuf2-v4l2.h>
  22. #include "vsp1_entity.h"
  23. struct vsp1_device;
  24. struct vsp1_pipeline;
  25. #define HISTO_PAD_SINK 0
  26. #define HISTO_PAD_SOURCE 1
  27. struct vsp1_histogram_buffer {
  28. struct vb2_v4l2_buffer buf;
  29. struct list_head queue;
  30. void *addr;
  31. };
  32. struct vsp1_histogram {
  33. struct vsp1_pipeline *pipe;
  34. struct vsp1_entity entity;
  35. struct video_device video;
  36. struct media_pad pad;
  37. const u32 *formats;
  38. unsigned int num_formats;
  39. size_t data_size;
  40. u32 meta_format;
  41. struct mutex lock;
  42. struct vb2_queue queue;
  43. spinlock_t irqlock;
  44. struct list_head irqqueue;
  45. wait_queue_head_t wait_queue;
  46. bool readout;
  47. };
  48. static inline struct vsp1_histogram *vdev_to_histo(struct video_device *vdev)
  49. {
  50. return container_of(vdev, struct vsp1_histogram, video);
  51. }
  52. static inline struct vsp1_histogram *subdev_to_histo(struct v4l2_subdev *subdev)
  53. {
  54. return container_of(subdev, struct vsp1_histogram, entity.subdev);
  55. }
  56. int vsp1_histogram_init(struct vsp1_device *vsp1, struct vsp1_histogram *histo,
  57. enum vsp1_entity_type type, const char *name,
  58. const struct vsp1_entity_operations *ops,
  59. const unsigned int *formats, unsigned int num_formats,
  60. size_t data_size, u32 meta_format);
  61. void vsp1_histogram_destroy(struct vsp1_entity *entity);
  62. struct vsp1_histogram_buffer *
  63. vsp1_histogram_buffer_get(struct vsp1_histogram *histo);
  64. void vsp1_histogram_buffer_complete(struct vsp1_histogram *histo,
  65. struct vsp1_histogram_buffer *buf,
  66. size_t size);
  67. #endif /* __VSP1_HISTO_H__ */