jpeg-core.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* linux/drivers/media/video/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. * @ioarea: JPEG IP memory region
  50. * @regs: JPEG IP registers mapping
  51. * @irq: JPEG IP irq
  52. * @clk: JPEG IP clock
  53. * @dev: JPEG IP struct device
  54. * @alloc_ctx: videobuf2 memory allocator's context
  55. */
  56. struct s5p_jpeg {
  57. struct mutex lock;
  58. struct spinlock slock;
  59. struct v4l2_device v4l2_dev;
  60. struct video_device *vfd_encoder;
  61. struct video_device *vfd_decoder;
  62. struct v4l2_m2m_dev *m2m_dev;
  63. struct resource *ioarea;
  64. void __iomem *regs;
  65. unsigned int irq;
  66. struct clk *clk;
  67. struct device *dev;
  68. void *alloc_ctx;
  69. };
  70. /**
  71. * struct jpeg_fmt - driver's internal color format data
  72. * @name: format descritpion
  73. * @fourcc: the fourcc code, 0 if not applicable
  74. * @depth: number of bits per pixel
  75. * @colplanes: number of color planes (1 for packed formats)
  76. * @h_align: horizontal alignment order (align to 2^h_align)
  77. * @v_align: vertical alignment order (align to 2^v_align)
  78. * @types: types of queue this format is applicable to
  79. */
  80. struct s5p_jpeg_fmt {
  81. char *name;
  82. u32 fourcc;
  83. int depth;
  84. int colplanes;
  85. int h_align;
  86. int v_align;
  87. u32 types;
  88. };
  89. /**
  90. * s5p_jpeg_q_data - parameters of one queue
  91. * @fmt: driver-specific format of this queue
  92. * @w: image width
  93. * @h: image height
  94. * @size: image buffer size in bytes
  95. */
  96. struct s5p_jpeg_q_data {
  97. struct s5p_jpeg_fmt *fmt;
  98. u32 w;
  99. u32 h;
  100. u32 size;
  101. };
  102. /**
  103. * s5p_jpeg_ctx - the device context data
  104. * @jpeg: JPEG IP device for this context
  105. * @mode: compression (encode) operation or decompression (decode)
  106. * @compr_quality: destination image quality in compression (encode) mode
  107. * @m2m_ctx: mem2mem device context
  108. * @out_q: source (output) queue information
  109. * @cap_fmt: destination (capture) queue queue information
  110. * @hdr_parsed: set if header has been parsed during decompression
  111. * @ctrl_handler: controls handler
  112. */
  113. struct s5p_jpeg_ctx {
  114. struct s5p_jpeg *jpeg;
  115. unsigned int mode;
  116. unsigned short compr_quality;
  117. unsigned short restart_interval;
  118. unsigned short subsampling;
  119. struct v4l2_m2m_ctx *m2m_ctx;
  120. struct s5p_jpeg_q_data out_q;
  121. struct s5p_jpeg_q_data cap_q;
  122. struct v4l2_fh fh;
  123. bool hdr_parsed;
  124. struct v4l2_ctrl_handler ctrl_handler;
  125. };
  126. /**
  127. * s5p_jpeg_buffer - description of memory containing input JPEG data
  128. * @size: buffer size
  129. * @curr: current position in the buffer
  130. * @data: pointer to the data
  131. */
  132. struct s5p_jpeg_buffer {
  133. unsigned long size;
  134. unsigned long curr;
  135. unsigned long data;
  136. };
  137. #endif /* JPEG_CORE_H */