diff options
-rw-r--r-- | drivers/media/common/cx2341x.c | 151 |
1 files changed, 93 insertions, 58 deletions
diff --git a/drivers/media/common/cx2341x.c b/drivers/media/common/cx2341x.c index 1dcc39b87bb7..121cda73ff88 100644 --- a/drivers/media/common/cx2341x.c +++ b/drivers/media/common/cx2341x.c | |||
@@ -1028,7 +1028,7 @@ static int cx2341x_api(void *priv, cx2341x_mbox_func func, | |||
1028 | return func(priv, cmd, args, 0, data); | 1028 | return func(priv, cmd, args, 0, data); |
1029 | } | 1029 | } |
1030 | 1030 | ||
1031 | #define NEQ(field) (old->field != new->field) | 1031 | #define CMP_FIELD(__old, __new, __field) (__old->__field != __new->__field) |
1032 | 1032 | ||
1033 | int cx2341x_update(void *priv, cx2341x_mbox_func func, | 1033 | int cx2341x_update(void *priv, cx2341x_mbox_func func, |
1034 | const struct cx2341x_mpeg_params *old, | 1034 | const struct cx2341x_mpeg_params *old, |
@@ -1042,20 +1042,22 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func, | |||
1042 | 11, /* VCD */ | 1042 | 11, /* VCD */ |
1043 | 12, /* SVCD */ | 1043 | 12, /* SVCD */ |
1044 | }; | 1044 | }; |
1045 | 1045 | int err; | |
1046 | int err = 0; | ||
1047 | int force = (old == NULL); | ||
1048 | u16 temporal = new->video_temporal_filter; | ||
1049 | 1046 | ||
1050 | cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0); | 1047 | cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0); |
1051 | 1048 | ||
1052 | if (force || NEQ(is_50hz)) { | 1049 | if (!old || |
1050 | CMP_FIELD(old, new, is_50hz)) { | ||
1053 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_RATE, 1, | 1051 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_RATE, 1, |
1054 | new->is_50hz); | 1052 | new->is_50hz); |
1055 | if (err) return err; | 1053 | if (err) |
1054 | return err; | ||
1056 | } | 1055 | } |
1057 | 1056 | ||
1058 | if (force || NEQ(width) || NEQ(height) || NEQ(video_encoding)) { | 1057 | if (!old || |
1058 | CMP_FIELD(old, new, width) || | ||
1059 | CMP_FIELD(old, new, height) || | ||
1060 | CMP_FIELD(old, new, video_encoding)) { | ||
1059 | u16 w = new->width; | 1061 | u16 w = new->width; |
1060 | u16 h = new->height; | 1062 | u16 h = new->height; |
1061 | 1063 | ||
@@ -1065,94 +1067,127 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func, | |||
1065 | } | 1067 | } |
1066 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_SIZE, 2, | 1068 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_SIZE, 2, |
1067 | h, w); | 1069 | h, w); |
1068 | if (err) return err; | 1070 | if (err) |
1071 | return err; | ||
1069 | } | 1072 | } |
1070 | if (force || NEQ(stream_type)) { | 1073 | if (!old || |
1074 | CMP_FIELD(old, new, stream_type)) { | ||
1071 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_STREAM_TYPE, 1, | 1075 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_STREAM_TYPE, 1, |
1072 | mpeg_stream_type[new->stream_type]); | 1076 | mpeg_stream_type[new->stream_type]); |
1073 | if (err) return err; | 1077 | if (err) |
1078 | return err; | ||
1074 | } | 1079 | } |
1075 | if (force || NEQ(video_aspect)) { | 1080 | if (!old || |
1081 | CMP_FIELD(old, new, video_aspect)) { | ||
1076 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_ASPECT_RATIO, 1, | 1082 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_ASPECT_RATIO, 1, |
1077 | 1 + new->video_aspect); | 1083 | 1 + new->video_aspect); |
1078 | if (err) return err; | 1084 | if (err) |
1085 | return err; | ||
1079 | } | 1086 | } |
1080 | if (force || NEQ(video_b_frames) || NEQ(video_gop_size)) { | 1087 | if (!old || |
1088 | CMP_FIELD(old, new, video_b_frames) || | ||
1089 | CMP_FIELD(old, new, video_gop_size)) { | ||
1081 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_GOP_PROPERTIES, 2, | 1090 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_GOP_PROPERTIES, 2, |
1082 | new->video_gop_size, new->video_b_frames + 1); | 1091 | new->video_gop_size, new->video_b_frames + 1); |
1083 | if (err) return err; | 1092 | if (err) |
1093 | return err; | ||
1084 | } | 1094 | } |
1085 | if (force || NEQ(video_gop_closure)) { | 1095 | if (!old || |
1096 | CMP_FIELD(old, new, video_gop_closure)) { | ||
1086 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_GOP_CLOSURE, 1, | 1097 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_GOP_CLOSURE, 1, |
1087 | new->video_gop_closure); | 1098 | new->video_gop_closure); |
1088 | if (err) return err; | 1099 | if (err) |
1100 | return err; | ||
1089 | } | 1101 | } |
1090 | if (force || NEQ(audio_properties)) { | 1102 | if (!old || |
1103 | CMP_FIELD(old, new, audio_properties)) { | ||
1091 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_AUDIO_PROPERTIES, | 1104 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_AUDIO_PROPERTIES, |
1092 | 1, new->audio_properties); | 1105 | 1, new->audio_properties); |
1093 | if (err) return err; | 1106 | if (err) |
1107 | return err; | ||
1094 | } | 1108 | } |
1095 | if (force || NEQ(audio_mute)) { | 1109 | if (!old || |
1110 | CMP_FIELD(old, new, audio_mute)) { | ||
1096 | err = cx2341x_api(priv, func, CX2341X_ENC_MUTE_AUDIO, 1, | 1111 | err = cx2341x_api(priv, func, CX2341X_ENC_MUTE_AUDIO, 1, |
1097 | new->audio_mute); | 1112 | new->audio_mute); |
1098 | if (err) return err; | 1113 | if (err) |
1114 | return err; | ||
1099 | } | 1115 | } |
1100 | if (force || NEQ(video_bitrate_mode) || NEQ(video_bitrate) || | 1116 | if (!old || |
1101 | NEQ(video_bitrate_peak)) { | 1117 | CMP_FIELD(old, new, video_bitrate_mode) || |
1118 | CMP_FIELD(old, new, video_bitrate) || | ||
1119 | CMP_FIELD(old, new, video_bitrate_peak)) { | ||
1102 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_BIT_RATE, 5, | 1120 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_BIT_RATE, 5, |
1103 | new->video_bitrate_mode, new->video_bitrate, | 1121 | new->video_bitrate_mode, new->video_bitrate, |
1104 | new->video_bitrate_peak / 400, 0, 0); | 1122 | new->video_bitrate_peak / 400, 0, 0); |
1105 | if (err) return err; | 1123 | if (err) |
1124 | return err; | ||
1106 | } | 1125 | } |
1107 | if (force || NEQ(video_spatial_filter_mode) || | 1126 | if (!old || |
1108 | NEQ(video_temporal_filter_mode) || | 1127 | CMP_FIELD(old, new, video_spatial_filter_mode) || |
1109 | NEQ(video_median_filter_type)) { | 1128 | CMP_FIELD(old, new, video_temporal_filter_mode) || |
1129 | CMP_FIELD(old, new, video_median_filter_type)) { | ||
1110 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_MODE, | 1130 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_MODE, |
1111 | 2, new->video_spatial_filter_mode | | 1131 | 2, |
1132 | new->video_spatial_filter_mode | | ||
1112 | (new->video_temporal_filter_mode << 1), | 1133 | (new->video_temporal_filter_mode << 1), |
1113 | new->video_median_filter_type); | 1134 | new->video_median_filter_type); |
1114 | if (err) return err; | 1135 | if (err) |
1136 | return err; | ||
1115 | } | 1137 | } |
1116 | if (force || NEQ(video_luma_median_filter_bottom) || | 1138 | if (!old || |
1117 | NEQ(video_luma_median_filter_top) || | 1139 | CMP_FIELD(old, new, video_luma_median_filter_bottom) || |
1118 | NEQ(video_chroma_median_filter_bottom) || | 1140 | CMP_FIELD(old, new, video_luma_median_filter_top) || |
1119 | NEQ(video_chroma_median_filter_top)) { | 1141 | CMP_FIELD(old, new, video_chroma_median_filter_bottom) || |
1142 | CMP_FIELD(old, new, video_chroma_median_filter_top)) { | ||
1120 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_CORING_LEVELS, 4, | 1143 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_CORING_LEVELS, 4, |
1121 | new->video_luma_median_filter_bottom, | 1144 | new->video_luma_median_filter_bottom, |
1122 | new->video_luma_median_filter_top, | 1145 | new->video_luma_median_filter_top, |
1123 | new->video_chroma_median_filter_bottom, | 1146 | new->video_chroma_median_filter_bottom, |
1124 | new->video_chroma_median_filter_top); | 1147 | new->video_chroma_median_filter_top); |
1125 | if (err) return err; | 1148 | if (err) |
1149 | return err; | ||
1126 | } | 1150 | } |
1127 | if (force || NEQ(video_luma_spatial_filter_type) || | 1151 | if (!old || |
1128 | NEQ(video_chroma_spatial_filter_type)) { | 1152 | CMP_FIELD(old, new, video_luma_spatial_filter_type) || |
1153 | CMP_FIELD(old, new, video_chroma_spatial_filter_type)) { | ||
1129 | err = cx2341x_api(priv, func, | 1154 | err = cx2341x_api(priv, func, |
1130 | CX2341X_ENC_SET_SPATIAL_FILTER_TYPE, | 1155 | CX2341X_ENC_SET_SPATIAL_FILTER_TYPE, |
1131 | 2, new->video_luma_spatial_filter_type, | 1156 | 2, new->video_luma_spatial_filter_type, |
1132 | new->video_chroma_spatial_filter_type); | 1157 | new->video_chroma_spatial_filter_type); |
1133 | if (err) return err; | 1158 | if (err) |
1159 | return err; | ||
1134 | } | 1160 | } |
1135 | if (force || NEQ(video_spatial_filter) || | 1161 | if (!old || |
1136 | old->video_temporal_filter != temporal) { | 1162 | CMP_FIELD(old, new, video_spatial_filter) || |
1163 | CMP_FIELD(old, new, video_temporal_filter)) { | ||
1137 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_PROPS, | 1164 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_PROPS, |
1138 | 2, new->video_spatial_filter, temporal); | 1165 | 2, new->video_spatial_filter, |
1139 | if (err) return err; | 1166 | new->video_temporal_filter); |
1167 | if (err) | ||
1168 | return err; | ||
1140 | } | 1169 | } |
1141 | if (force || NEQ(video_temporal_decimation)) { | 1170 | if (!old || |
1171 | CMP_FIELD(old, new, video_temporal_decimation)) { | ||
1142 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_DROP_RATE, | 1172 | err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_DROP_RATE, |
1143 | 1, new->video_temporal_decimation); | 1173 | 1, new->video_temporal_decimation); |
1144 | if (err) return err; | 1174 | if (err) |
1175 | return err; | ||
1145 | } | 1176 | } |
1146 | if (force || NEQ(video_mute) || | 1177 | if (!old || |
1147 | (new->video_mute && NEQ(video_mute_yuv))) { | 1178 | CMP_FIELD(old, new, video_mute) || |
1179 | (new->video_mute && CMP_FIELD(old, new, video_mute_yuv))) { | ||
1148 | err = cx2341x_api(priv, func, CX2341X_ENC_MUTE_VIDEO, 1, | 1180 | err = cx2341x_api(priv, func, CX2341X_ENC_MUTE_VIDEO, 1, |
1149 | new->video_mute | (new->video_mute_yuv << 8)); | 1181 | new->video_mute | (new->video_mute_yuv << 8)); |
1150 | if (err) return err; | 1182 | if (err) |
1183 | return err; | ||
1151 | } | 1184 | } |
1152 | if (force || NEQ(stream_insert_nav_packets)) { | 1185 | if (!old || |
1186 | CMP_FIELD(old, new, stream_insert_nav_packets)) { | ||
1153 | err = cx2341x_api(priv, func, CX2341X_ENC_MISC, 2, | 1187 | err = cx2341x_api(priv, func, CX2341X_ENC_MISC, 2, |
1154 | 7, new->stream_insert_nav_packets); | 1188 | 7, new->stream_insert_nav_packets); |
1155 | if (err) return err; | 1189 | if (err) |
1190 | return err; | ||
1156 | } | 1191 | } |
1157 | return 0; | 1192 | return 0; |
1158 | } | 1193 | } |