vsp1_histo.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * vsp1_histo.h -- R-Car VSP1 Histogram API
  4. *
  5. * Copyright (C) 2016 Renesas Electronics Corporation
  6. * Copyright (C) 2016 Laurent Pinchart
  7. *
  8. * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  9. */
  10. #ifndef __VSP1_HISTO_H__
  11. #define __VSP1_HISTO_H__
  12. #include <linux/list.h>
  13. #include <linux/mutex.h>
  14. #include <linux/spinlock.h>
  15. #include <media/media-entity.h>
  16. #include <media/v4l2-dev.h>
  17. #include <media/videobuf2-v4l2.h>
  18. #include "vsp1_entity.h"
  19. struct vsp1_device;
  20. #define HISTO_PAD_SINK 0
  21. #define HISTO_PAD_SOURCE 1
  22. struct vsp1_histogram_buffer {
  23. struct vb2_v4l2_buffer buf;
  24. struct list_head queue;
  25. void *addr;
  26. };
  27. struct vsp1_histogram {
  28. struct vsp1_entity entity;
  29. struct video_device video;
  30. struct media_pad pad;
  31. const u32 *formats;
  32. unsigned int num_formats;
  33. size_t data_size;
  34. u32 meta_format;
  35. struct mutex lock;
  36. struct vb2_queue queue;
  37. spinlock_t irqlock;
  38. struct list_head irqqueue;
  39. wait_queue_head_t wait_queue;
  40. bool readout;
  41. };
  42. static inline struct vsp1_histogram *vdev_to_histo(struct video_device *vdev)
  43. {
  44. return container_of(vdev, struct vsp1_histogram, video);
  45. }
  46. static inline struct vsp1_histogram *subdev_to_histo(struct v4l2_subdev *subdev)
  47. {
  48. return container_of(subdev, struct vsp1_histogram, entity.subdev);
  49. }
  50. int vsp1_histogram_init(struct vsp1_device *vsp1, struct vsp1_histogram *histo,
  51. enum vsp1_entity_type type, const char *name,
  52. const struct vsp1_entity_operations *ops,
  53. const unsigned int *formats, unsigned int num_formats,
  54. size_t data_size, u32 meta_format);
  55. void vsp1_histogram_destroy(struct vsp1_entity *entity);
  56. struct vsp1_histogram_buffer *
  57. vsp1_histogram_buffer_get(struct vsp1_histogram *histo);
  58. void vsp1_histogram_buffer_complete(struct vsp1_histogram *histo,
  59. struct vsp1_histogram_buffer *buf,
  60. size_t size);
  61. #endif /* __VSP1_HISTO_H__ */