aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/omap3isp/isppreview.c134
1 files changed, 62 insertions, 72 deletions
diff --git a/drivers/media/video/omap3isp/isppreview.c b/drivers/media/video/omap3isp/isppreview.c
index e294f13741f8..fd1807d36d40 100644
--- a/drivers/media/video/omap3isp/isppreview.c
+++ b/drivers/media/video/omap3isp/isppreview.c
@@ -725,44 +725,77 @@ preview_config_yc_range(struct isp_prev_device *prev, const void *yclimit)
725struct preview_update { 725struct preview_update {
726 void (*config)(struct isp_prev_device *, const void *); 726 void (*config)(struct isp_prev_device *, const void *);
727 void (*enable)(struct isp_prev_device *, u8); 727 void (*enable)(struct isp_prev_device *, u8);
728 unsigned int param_offset;
729 unsigned int param_size;
730 unsigned int config_offset;
728 bool skip; 731 bool skip;
729}; 732};
730 733
731/* Keep the array indexed by the OMAP3ISP_PREV_* bit number. */ 734/* Keep the array indexed by the OMAP3ISP_PREV_* bit number. */
732static struct preview_update update_attrs[] = { 735static const struct preview_update update_attrs[] = {
733 /* OMAP3ISP_PREV_LUMAENH */ { 736 /* OMAP3ISP_PREV_LUMAENH */ {
734 preview_config_luma_enhancement, 737 preview_config_luma_enhancement,
735 preview_enable_luma_enhancement, 738 preview_enable_luma_enhancement,
739 offsetof(struct prev_params, luma),
740 FIELD_SIZEOF(struct prev_params, luma),
741 offsetof(struct omap3isp_prev_update_config, luma),
736 }, /* OMAP3ISP_PREV_INVALAW */ { 742 }, /* OMAP3ISP_PREV_INVALAW */ {
737 NULL, 743 NULL,
738 preview_enable_invalaw, 744 preview_enable_invalaw,
739 }, /* OMAP3ISP_PREV_HRZ_MED */ { 745 }, /* OMAP3ISP_PREV_HRZ_MED */ {
740 preview_config_hmed, 746 preview_config_hmed,
741 preview_enable_hmed, 747 preview_enable_hmed,
748 offsetof(struct prev_params, hmed),
749 FIELD_SIZEOF(struct prev_params, hmed),
750 offsetof(struct omap3isp_prev_update_config, hmed),
742 }, /* OMAP3ISP_PREV_CFA */ { 751 }, /* OMAP3ISP_PREV_CFA */ {
743 preview_config_cfa, 752 preview_config_cfa,
744 preview_enable_cfa, 753 preview_enable_cfa,
754 offsetof(struct prev_params, cfa),
755 FIELD_SIZEOF(struct prev_params, cfa),
756 offsetof(struct omap3isp_prev_update_config, cfa),
745 }, /* OMAP3ISP_PREV_CHROMA_SUPP */ { 757 }, /* OMAP3ISP_PREV_CHROMA_SUPP */ {
746 preview_config_chroma_suppression, 758 preview_config_chroma_suppression,
747 preview_enable_chroma_suppression, 759 preview_enable_chroma_suppression,
760 offsetof(struct prev_params, csup),
761 FIELD_SIZEOF(struct prev_params, csup),
762 offsetof(struct omap3isp_prev_update_config, csup),
748 }, /* OMAP3ISP_PREV_WB */ { 763 }, /* OMAP3ISP_PREV_WB */ {
749 preview_config_whitebalance, 764 preview_config_whitebalance,
750 NULL, 765 NULL,
766 offsetof(struct prev_params, wbal),
767 FIELD_SIZEOF(struct prev_params, wbal),
768 offsetof(struct omap3isp_prev_update_config, wbal),
751 }, /* OMAP3ISP_PREV_BLKADJ */ { 769 }, /* OMAP3ISP_PREV_BLKADJ */ {
752 preview_config_blkadj, 770 preview_config_blkadj,
753 NULL, 771 NULL,
772 offsetof(struct prev_params, blkadj),
773 FIELD_SIZEOF(struct prev_params, blkadj),
774 offsetof(struct omap3isp_prev_update_config, blkadj),
754 }, /* OMAP3ISP_PREV_RGB2RGB */ { 775 }, /* OMAP3ISP_PREV_RGB2RGB */ {
755 preview_config_rgb_blending, 776 preview_config_rgb_blending,
756 NULL, 777 NULL,
778 offsetof(struct prev_params, rgb2rgb),
779 FIELD_SIZEOF(struct prev_params, rgb2rgb),
780 offsetof(struct omap3isp_prev_update_config, rgb2rgb),
757 }, /* OMAP3ISP_PREV_COLOR_CONV */ { 781 }, /* OMAP3ISP_PREV_COLOR_CONV */ {
758 preview_config_rgb_to_ycbcr, 782 preview_config_rgb_to_ycbcr,
759 NULL, 783 NULL,
784 offsetof(struct prev_params, csc),
785 FIELD_SIZEOF(struct prev_params, csc),
786 offsetof(struct omap3isp_prev_update_config, csc),
760 }, /* OMAP3ISP_PREV_YC_LIMIT */ { 787 }, /* OMAP3ISP_PREV_YC_LIMIT */ {
761 preview_config_yc_range, 788 preview_config_yc_range,
762 NULL, 789 NULL,
790 offsetof(struct prev_params, yclimit),
791 FIELD_SIZEOF(struct prev_params, yclimit),
792 offsetof(struct omap3isp_prev_update_config, yclimit),
763 }, /* OMAP3ISP_PREV_DEFECT_COR */ { 793 }, /* OMAP3ISP_PREV_DEFECT_COR */ {
764 preview_config_dcor, 794 preview_config_dcor,
765 preview_enable_dcor, 795 preview_enable_dcor,
796 offsetof(struct prev_params, dcor),
797 FIELD_SIZEOF(struct prev_params, dcor),
798 offsetof(struct omap3isp_prev_update_config, dcor),
766 }, /* OMAP3ISP_PREV_GAMMABYPASS */ { 799 }, /* OMAP3ISP_PREV_GAMMABYPASS */ {
767 NULL, 800 NULL,
768 preview_enable_gammabypass, 801 preview_enable_gammabypass,
@@ -778,15 +811,25 @@ static struct preview_update update_attrs[] = {
778 }, /* OMAP3ISP_PREV_NF */ { 811 }, /* OMAP3ISP_PREV_NF */ {
779 preview_config_noisefilter, 812 preview_config_noisefilter,
780 preview_enable_noisefilter, 813 preview_enable_noisefilter,
814 offsetof(struct prev_params, nf),
815 FIELD_SIZEOF(struct prev_params, nf),
816 offsetof(struct omap3isp_prev_update_config, nf),
781 }, /* OMAP3ISP_PREV_GAMMA */ { 817 }, /* OMAP3ISP_PREV_GAMMA */ {
782 preview_config_gammacorrn, 818 preview_config_gammacorrn,
783 NULL, 819 NULL,
820 offsetof(struct prev_params, gamma),
821 FIELD_SIZEOF(struct prev_params, gamma),
822 offsetof(struct omap3isp_prev_update_config, gamma),
784 }, /* OMAP3ISP_PREV_CONTRAST */ { 823 }, /* OMAP3ISP_PREV_CONTRAST */ {
785 preview_config_contrast, 824 preview_config_contrast,
786 NULL, true, 825 NULL,
826 offsetof(struct prev_params, contrast),
827 0, true,
787 }, /* OMAP3ISP_PREV_BRIGHTNESS */ { 828 }, /* OMAP3ISP_PREV_BRIGHTNESS */ {
788 preview_config_brightness, 829 preview_config_brightness,
789 NULL, true, 830 NULL,
831 offsetof(struct prev_params, brightness),
832 0, true,
790 }, 833 },
791}; 834};
792 835
@@ -803,75 +846,22 @@ static struct preview_update update_attrs[] = {
803static u32 846static u32
804__preview_get_ptrs(struct prev_params *params, void **param, 847__preview_get_ptrs(struct prev_params *params, void **param,
805 struct omap3isp_prev_update_config *configs, 848 struct omap3isp_prev_update_config *configs,
806 void __user **config, u32 bit) 849 void __user **config, unsigned int index)
807{ 850{
808#define CHKARG(cfgs, cfg, field) \ 851 const struct preview_update *info = &update_attrs[index];
809 if (cfgs && cfg) { \
810 *(cfg) = (cfgs)->field; \
811 }
812 852
813 switch (bit) { 853 if (index >= ARRAY_SIZE(update_attrs)) {
814 case OMAP3ISP_PREV_HRZ_MED: 854 if (config)
815 *param = &params->hmed; 855 *config = NULL;
816 CHKARG(configs, config, hmed)
817 return sizeof(params->hmed);
818 case OMAP3ISP_PREV_NF:
819 *param = &params->nf;
820 CHKARG(configs, config, nf)
821 return sizeof(params->nf);
822 break;
823 case OMAP3ISP_PREV_CFA:
824 *param = &params->cfa;
825 CHKARG(configs, config, cfa)
826 return sizeof(params->cfa);
827 case OMAP3ISP_PREV_LUMAENH:
828 *param = &params->luma;
829 CHKARG(configs, config, luma)
830 return sizeof(params->luma);
831 case OMAP3ISP_PREV_CHROMA_SUPP:
832 *param = &params->csup;
833 CHKARG(configs, config, csup)
834 return sizeof(params->csup);
835 case OMAP3ISP_PREV_DEFECT_COR:
836 *param = &params->dcor;
837 CHKARG(configs, config, dcor)
838 return sizeof(params->dcor);
839 case OMAP3ISP_PREV_BLKADJ:
840 *param = &params->blkadj;
841 CHKARG(configs, config, blkadj)
842 return sizeof(params->blkadj);
843 case OMAP3ISP_PREV_YC_LIMIT:
844 *param = &params->yclimit;
845 CHKARG(configs, config, yclimit)
846 return sizeof(params->yclimit);
847 case OMAP3ISP_PREV_RGB2RGB:
848 *param = &params->rgb2rgb;
849 CHKARG(configs, config, rgb2rgb)
850 return sizeof(params->rgb2rgb);
851 case OMAP3ISP_PREV_COLOR_CONV:
852 *param = &params->csc;
853 CHKARG(configs, config, csc)
854 return sizeof(params->csc);
855 case OMAP3ISP_PREV_WB:
856 *param = &params->wbal;
857 CHKARG(configs, config, wbal)
858 return sizeof(params->wbal);
859 case OMAP3ISP_PREV_GAMMA:
860 *param = &params->gamma;
861 CHKARG(configs, config, gamma)
862 return sizeof(params->gamma);
863 case OMAP3ISP_PREV_CONTRAST:
864 *param = &params->contrast;
865 return 0;
866 case OMAP3ISP_PREV_BRIGHTNESS:
867 *param = &params->brightness;
868 return 0;
869 default:
870 *param = NULL; 856 *param = NULL;
871 *config = NULL; 857 return 0;
872 break;
873 } 858 }
874 return 0; 859
860 if (configs && config)
861 *config = *(void **)((void *)configs + info->config_offset);
862
863 *param = (void *)params + info->param_offset;
864 return info->param_size;
875} 865}
876 866
877/* 867/*
@@ -886,8 +876,8 @@ __preview_get_ptrs(struct prev_params *params, void **param,
886static int preview_config(struct isp_prev_device *prev, 876static int preview_config(struct isp_prev_device *prev,
887 struct omap3isp_prev_update_config *cfg) 877 struct omap3isp_prev_update_config *cfg)
888{ 878{
879 const struct preview_update *attr;
889 struct prev_params *params; 880 struct prev_params *params;
890 struct preview_update *attr;
891 int i, bit, rval = 0; 881 int i, bit, rval = 0;
892 882
893 if (cfg->update == 0) 883 if (cfg->update == 0)
@@ -914,7 +904,7 @@ static int preview_config(struct isp_prev_device *prev,
914 void *to = NULL, __user *from = NULL; 904 void *to = NULL, __user *from = NULL;
915 unsigned long sz = 0; 905 unsigned long sz = 0;
916 906
917 sz = __preview_get_ptrs(params, &to, cfg, &from, bit); 907 sz = __preview_get_ptrs(params, &to, cfg, &from, i);
918 if (to && from && sz) { 908 if (to && from && sz) {
919 if (copy_from_user(to, from, sz)) { 909 if (copy_from_user(to, from, sz)) {
920 rval = -EFAULT; 910 rval = -EFAULT;
@@ -942,7 +932,7 @@ static int preview_config(struct isp_prev_device *prev,
942static void preview_setup_hw(struct isp_prev_device *prev) 932static void preview_setup_hw(struct isp_prev_device *prev)
943{ 933{
944 struct prev_params *params = &prev->params; 934 struct prev_params *params = &prev->params;
945 struct preview_update *attr; 935 const struct preview_update *attr;
946 unsigned int bit; 936 unsigned int bit;
947 unsigned int i; 937 unsigned int i;
948 void *param_ptr; 938 void *param_ptr;
@@ -960,7 +950,7 @@ static void preview_setup_hw(struct isp_prev_device *prev)
960 if (params->features & bit) { 950 if (params->features & bit) {
961 if (attr->config) { 951 if (attr->config) {
962 __preview_get_ptrs(params, &param_ptr, NULL, 952 __preview_get_ptrs(params, &param_ptr, NULL,
963 NULL, bit); 953 NULL, i);
964 attr->config(prev, param_ptr); 954 attr->config(prev, param_ptr);
965 } 955 }
966 if (attr->enable) 956 if (attr->enable)