jpeg-core.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* linux/drivers/media/platform/s5p-jpeg/jpeg-core.h
  2. *
  3. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef JPEG_CORE_H_
  13. #define JPEG_CORE_H_
  14. #include <media/v4l2-device.h>
  15. #include <media/v4l2-fh.h>
  16. #include <media/v4l2-ctrls.h>
  17. #define S5P_JPEG_M2M_NAME "s5p-jpeg"
  18. /* JPEG compression quality setting */
  19. #define S5P_JPEG_COMPR_QUAL_BEST 0
  20. #define S5P_JPEG_COMPR_QUAL_WORST 3
  21. /* JPEG RGB to YCbCr conversion matrix coefficients */
  22. #define S5P_JPEG_COEF11 0x4d
  23. #define S5P_JPEG_COEF12 0x97
  24. #define S5P_JPEG_COEF13 0x1e
  25. #define S5P_JPEG_COEF21 0x2c
  26. #define S5P_JPEG_COEF22 0x57
  27. #define S5P_JPEG_COEF23 0x83
  28. #define S5P_JPEG_COEF31 0x83
  29. #define S5P_JPEG_COEF32 0x6e
  30. #define S5P_JPEG_COEF33 0x13
  31. /* a selection of JPEG markers */
  32. #define TEM 0x01
  33. #define SOF0 0xc0
  34. #define RST 0xd0
  35. #define SOI 0xd8
  36. #define EOI 0xd9
  37. #define DHP 0xde
  38. /* Flags that indicate a format can be used for capture/output */
  39. #define MEM2MEM_CAPTURE (1 << 0)
  40. #define MEM2MEM_OUTPUT (1 << 1)
  41. /**
  42. * struct s5p_jpeg - JPEG IP abstraction
  43. * @lock: the mutex protecting this structure
  44. * @slock: spinlock protecting the device contexts
  45. * @v4l2_dev: v4l2 device for mem2mem mode
  46. * @vfd_encoder: video device node for encoder mem2mem mode
  47. * @vfd_decoder: video device node for decoder mem2mem mode
  48. * @m2m_dev: v4l2 mem2mem device data
  49. * @regs: JPEG IP registers mapping
  50. * @irq: JPEG IP irq
  51. * @clk: JPEG IP clock
  52. * @dev: JPEG IP struct device
  53. * @alloc_ctx: videobuf2 memory allocator's context
  54. */
  55. struct s5p_jpeg {
  56. struct mutex lock;
  57. spinlock_t slock;
  58. struct v4l2_device v4l2_dev;
  59. struct video_device *vfd_encoder;
  60. struct video_device *vfd_decoder;
  61. struct v4l2_m2m_dev *m2m_dev;
  62. void __iomem *regs;
  63. unsigned int irq;
  64. struct clk *clk;
  65. struct device *dev;
  66. void *alloc_ctx;
  67. };
  68. /**
  69. * struct jpeg_fmt - driver's internal color format data
  70. * @name: format descritpion
  71. * @fourcc: the fourcc code, 0 if not applicable
  72. * @depth: number of bits per pixel
  73. * @colplanes: number of color planes (1 for packed formats)
  74. * @h_align: horizontal alignment order (align to 2^h_align)
  75. * @v_align: vertical alignment order (align to 2^v_align)
  76. * @types: types of queue this format is applicable to
  77. */
  78. struct s5p_jpeg_fmt {
  79. char *name;
  80. u32 fourcc;
  81. int depth;
  82. int colplanes;
  83. int h_align;
  84. int v_align;
  85. u32 types;
  86. };
  87. /**
  88. * s5p_jpeg_q_data - parameters of one queue
  89. * @fmt: driver-specific format of this queue
  90. * @w: image width
  91. * @h: image height
  92. * @size: image buffer size in bytes
  93. */
  94. struct s5p_jpeg_q_data {
  95. struct s5p_jpeg_fmt *fmt;
  96. u32 w;
  97. u32 h;
  98. u32 size;
  99. };
  100. /**
  101. * s5p_jpeg_ctx - the device context data
  102. * @jpeg: JPEG IP device for this context
  103. * @mode: compression (encode) operation or decompression (decode)
  104. * @compr_quality: destination image quality in compression (encode) mode
  105. * @m2m_ctx: mem2mem device context
  106. * @out_q: source (output) queue information
  107. * @cap_fmt: destination (capture) queue queue information
  108. * @hdr_parsed: set if header has been parsed during decompression
  109. * @ctrl_handler: controls handler
  110. */
  111. struct s5p_jpeg_ctx {
  112. struct s5p_jpeg *jpeg;
  113. unsigned int mode;
  114. unsigned short compr_quality;
  115. unsigned short restart_interval;
  116. unsigned short subsampling;
  117. struct v4l2_m2m_ctx *m2m_ctx;
  118. struct s5p_jpeg_q_data out_q;
  119. struct s5p_jpeg_q_data cap_q;
  120. struct v4l2_fh fh;
  121. bool hdr_parsed;
  122. struct v4l2_ctrl_handler ctrl_handler;
  123. };
  124. /**
  125. * s5p_jpeg_buffer - description of memory containing input JPEG data
  126. * @size: buffer size
  127. * @curr: current position in the buffer
  128. * @data: pointer to the data
  129. */
  130. struct s5p_jpeg_buffer {
  131. unsigned long size;
  132. unsigned long curr;
  133. unsigned long data;
  134. };
  135. #endif /* JPEG_CORE_H */